51 Commits
061 ... 081

Author SHA1 Message Date
b610dc337b 'README.md' ändern 2018-06-14 15:24:33 +02:00
f195addea8 version 0.3.1 (81) 2018-06-13 18:29:16 +02:00
41a0becd4f typo 2018-06-13 13:49:47 +02:00
9b7a85cabe code clean up 2018-06-12 16:24:12 +02:00
cc4e73c45d InfoAlert & ProcessBuilder
* we use an Alert now to display Info Messages
* use ProcessBuilder instead of Runtime.exec()
2018-06-12 16:01:21 +02:00
c6a40f8937 updated some libs
* jfoenix 9.0.3 -> 9.0.4
* sqlite-jdbc 3.21.0.1 -> 3.23.1
* google-api-services-drive v3-rev99-1.23.0 -> v3-rev120-1.23.0
* jackson-core 2.9.4 -> 2.9.5
* maven-shade-plugin 3.1.0 -> 3.1.1
2018-06-06 17:54:22 +02:00
e13c84382f biuld against java 10 2018-05-30 19:41:49 +02:00
ea34f10c09 fixed Hamburger icon has wrong color after color change 2018-04-28 12:53:01 +02:00
4e4d32dc97 Update README.md 2018-04-28 12:24:40 +02:00
5758b23bff Merge branch 'master' into develop 2018-04-28 12:21:37 +02:00
1e7cea86ad code cleanup
* log4j 2.10.0 -> 2.11.0
2018-04-28 12:17:12 +02:00
433767f81c Merge remote-tracking branch 'origin/develop' into develop 2018-04-05 09:55:09 +02:00
f9f63c0f3c code cleanup 2018-04-05 09:54:45 +02:00
fcaffecabf text fix 2018-03-22 18:54:56 +01:00
7813778502 small cleanup 2018-03-22 11:54:30 +01:00
662188813b removed workaround for xPosHelper Bug 2018-02-24 17:00:43 +01:00
b915cf7ad9 removed last unnecessary reboot
* needs more testing, especialy under Windows
* test on a completly fresh setup
2018-02-20 21:22:10 +01:00
b4fc36621a code cleanup
removed some unnecessary save calls
* removed some unnecessary things after opening a directorychooser
* typo fixes
2018-02-18 18:27:36 +01:00
061f58105a documentation cleanups, code cleanup
* removed one unnecessary restart
* added warning if the ROM directory could not be opened
2018-02-18 13:57:30 +01:00
3a6a7b7cce * jfoenix 9.0.1 -> 9.0.2
* code clean up
* last time played and playtime button are now large enough
2018-02-17 17:49:12 +01:00
f7675cf277 Update README.md 2018-02-14 22:55:27 +01:00
4932731987 Update README.md 2018-02-14 22:53:14 +01:00
2e3395caea minor fixes
* fixed a few typos
* fixed window is resiable to 0x0
* * formating work work
2018-02-04 15:19:36 +01:00
e9d033f121 Update README.md 2018-02-03 18:05:09 +01:00
54078eb99f clean up 2018-02-03 17:51:38 +01:00
79cb1c2476 fixed games are not loaded to mwc
* fixed games are not loaded to mwc
* fixed processbuilder
2018-02-03 15:39:35 +01:00
b88c530ac2 use a ProcessBuilder instead of Runtime.exec 2018-02-03 14:22:41 +01:00
88e31468d4 made choicebox matreial styled
* made choicebox matreial styled
* little code clean up
2018-02-03 12:04:14 +01:00
84b5eaedcd reworked startup process
* cemu is showing a loading screen while loading the roms
* jackson core 2.9.3 -> 2.9.4
2018-01-31 17:01:47 +01:00
f331fb57a4 added ability to edit launch command, WIP
WARNING THIS IS NOT TESTED
2018-01-19 01:14:01 +01:00
a9f675ee5e Update README.md 2018-01-13 23:35:33 +01:00
fe4fcb45d7 travis fix, first try 2018-01-13 00:13:34 +01:00
52c2912ba2 maven compile plugin 3.7.0 2018-01-13 00:09:13 +01:00
46455e9e9d Java 9, updated a few libs
* cemu_UI targets now Java 9
* jfoenix 1.11.1 -> 9.0.1
* minimal-json 0.9.4 -> 0.9.5
* log4j 2.9.1 -> 2.10.0
* commons-io 2.5 -> 2.6
* jackson-core 2.9.2 -> 2.9.3
* javax.servlet-api 4.0.0-b01 -> 4.0.0
2018-01-12 23:52:44 +01:00
1e2d4088e9 Merge pull request #15 from Seil0/develop
release 0.2.3
2018-01-12 20:08:03 +01:00
d3acf387d9 code clean up 2017-12-26 17:33:14 +01:00
de2c8d76ea Update CONTRIBUTING.md 2017-12-21 17:33:54 +01:00
9be124a5f3 Update CONTRIBUTING.md 2017-12-21 17:33:22 +01:00
a020992cc2 release 0.3.2 build 071
* added missing translation
2017-12-21 11:02:54 +01:00
8c5d511dfb removed log.txt 2017-12-19 22:18:58 +01:00
c73d02c433 added german local 2017-12-19 22:18:22 +01:00
34bed89b40 language work part 2
* dialogs support different languages now too
* finished english language pack
2017-12-19 21:35:49 +01:00
ce52628554 language work part 1
* added support for different languages
* added english locals
2017-12-19 19:08:12 +01:00
fc0be39455 code clean up
* cleaned up the playBtn code
* added language section in settings
2017-12-18 09:58:32 +01:00
595bfbe07d bummped buildnumber to 065 2017-12-16 23:05:26 +01:00
599669f0f2 fixed a bug that prefent the cloud controller from geting the latest cloud sync 2017-12-13 00:07:20 +01:00
42b8434a58 Cloud sync rework
* reworked the hole cloud sync controller
this will make it more save to use the cloud sync
THIS IS WORK IN PROGRESS, NOT READY FOR DAILY USE!
2017-12-12 23:52:54 +01:00
9b443dfeae small DBController code clean up 2017-12-12 19:19:01 +01:00
c70786cdf4 minor ui improvements 2017-12-12 19:01:17 +01:00
a3a7d415c7 fixed a few bugs
* games.db -> reference_games.db
* fix picture cache path under linux
2017-12-12 12:02:28 +01:00
9ccb7e6b42 better coding style
* used gettersand setter for accessing the mainparts of the UI elements, uch aus primarStage
* dbController -> DBController
2017-12-12 11:19:33 +01:00
26 changed files with 1280 additions and 998 deletions

View File

@ -18,12 +18,12 @@
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/main"/>
<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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -1,13 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=9
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.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=9

View File

@ -1 +1,4 @@
language: java
language: java
jdk:
- oraclejdk9
- oraclejdk10

View File

@ -1,7 +1,13 @@
# Contributing to cemu_UI
The following is a set of guidelines for contributing to cemu_UI.
## Java Sytleguide
## Translating
If you don't want to contibute any code you can support this project by translating it! The translation files are stored in "src/main/resources/locals".
# Contributing code
If you want to contibute code please read the java code styleguide.
## Java code sytleguide
If your willing to contribute to cemu_UI please us the following example as guide and rules to design your code.
* Use names for methods and variables that clarify their purpose. (This will help a lot to understand the code)
* Use as many spaces as necessary to make the code clear, but as little as possible.

View File

@ -1,16 +1,19 @@
# cemu_UI
![Total Downloads](https://img.shields.io/github/downloads/Seil0/cemu_UI/total.svg?style=flat-square)
[![](https://img.shields.io/travis/Seil0/cemu_UI/master.svg?style=flat-square)](https://travis-ci.org/Seil0/cemu_UI)
[![Build](https://img.shields.io/travis/Seil0/cemu_UI/master.svg?style=flat-square)](https://travis-ci.org/Seil0/cemu_UI)
[![Latest](https://img.shields.io/github/release/Seil0/cemu_UI/all.svg?style=flat-square)](https://github.com/Seil0/cemu_UI/releases)
[![HitCount](http://hits.dwyl.io/Seil0/cemu_UI.svg)](http://hits.dwyl.io/Seil0/cemu_UI)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0)
cemu_UI is a simple, material design graphical frontend for [cemu](http://cemu.info/), a Wii U emulator. Downloads can be found [here](https://github.com/Seil0/cemu_UI/releases).
cemu_UI is a simple, material design graphical frontend for [cemu](http://cemu.info/), a Wii U emulator. Downloads can be found [here](https://git.mosad.xyz/Seil0/cemu_UI/releases).
## Installation
Simply download the cemu_UI.jar from [releases](https://github.com/Seil0/cemu_UI/releases), make sure you have the latest version of java 8 oracle jre/jdk installed and open the file. cemu_UI creats a new directory "C:\Users\USERNAME\Documents\cemu_UI", where the database, settings and covers are stored. **first start can take while!**
Simply download the cemu_UI.jar from [Releases](https://git.mosad.xyz/Seil0/cemu_UI/releases), make sure you have the latest version of java 8 oracle jre/jdk installed and open the file. cemu_UI creats a new directory "C:\Users\USERNAME\Documents\cemu_UI", where the database, settings and covers are stored. **first start can take while!**
If you want to use the cloud sync function read the [wiki](https://github.com/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully!
If you want to use the cloud sync function read the [wiki](https://git.mosad.xyz/Seil0/cemu_UI/wiki#cloud-savegame-syncronisation) carefully!
### [FAQ](https://git.mosad.xyz/Seil0/cemu_UI/wiki#faq)
## Features
@ -20,23 +23,17 @@ If you want to use the cloud sync function read the [wiki](https://github.com/Se
* add updates and dlcs easier (only adding not downloading!)
* automatic rom detection (only .rpx files with a app.xml)
* customisable UI
* [sync savegames via google drive](https://github.com/Seil0/cemu_UI/wiki)
* [sync savegames via google drive](https://git.mosad.xyz/Seil0/cemu_UI/wiki)
* [smmdb api](https://github.com/Tarnadas/smmdb) integration
## [planed Features](https://github.com/Seil0/cemu_UI/projects/1) (no ETA)
## [planed Features](https://git.mosad.xyz/Seil0/cemu_UI/milestones)
* Controller support
* more UI improvements
* support more rom file formats in automatic detection
### If you have another idea, make a "new issue" with the ![#f03c15](https://placehold.it/15/fbca04/000000?text=+)`idea` lable
### If you have another idea, make a new issue!
## [FAQ](https://github.com/Seil0/cemu_UI/wiki#faq)
### [building from source](https://github.com/Seil0/cemu_UI/wiki/Documantation)
### [building from source](https://git.mosad.xyz/Seil0/cemu_UI/wiki/Documantation)
## Screenshots
![Screenshot](/downloadContent/cemu_UI4.png)
![Screenshot](https://git.mosad.xyz/Seil0/cemu_UI/raw/branch/master/downloadContent/cemu_UI4.png)

77
pom.xml
View File

@ -4,16 +4,14 @@
<groupId>com</groupId>
<artifactId>cemu_UI</artifactId>
<version>0.2.2-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cemu_UI</name>
<description>cemu_UI is a simple, material design graphical frontend for cemu, a Wii U emulator</description>
<url>http://www.kellerkinder.xyz</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
@ -21,44 +19,44 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>1.11.1</version>
<version>9.0.4</version>
</dependency>
<dependency>
<groupId>com.eclipsesource.minimal-json</groupId>
<artifactId>minimal-json</artifactId>
<version>0.9.4</version>
<version>0.9.5</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0.1</version>
<version>3.23.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-vfs2 -->
@ -109,7 +107,7 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v3-rev87-1.23.0</version>
<version>v3-rev120-1.23.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
@ -152,14 +150,14 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.2</version>
<version>2.9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0-b01</version>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
@ -180,13 +178,24 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>9</source>
<target>9</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
@ -194,18 +203,18 @@
<goal>shade</goal>
</goals>
<configuration>
<finalName>cemu_UI</finalName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.cemu_UI.application.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.cemu_UI.application.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.application;
import java.io.File;
@ -48,14 +47,13 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
Stage primaryStage;
public MainWindowController mainWindowController; // TODO find a better way
CloudController cloudController;
AnchorPane pane;
Scene scene; // TODO make private
private Stage primaryStage;
private MainWindowController mainWindowController;
private CloudController cloudController;
private AnchorPane pane;
private Scene scene;
private static String userHome = System.getProperty("user.home");
private static String userName = System.getProperty("user.name");
private static String osName = System.getProperty("os.name");
@ -64,14 +62,12 @@ public class Main extends Application {
private static String javaVers = System.getProperty("java.version");
private static String javaVend= System.getProperty("java.vendor");
private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db";
public String dirWin = userHome + "/Documents/cemu_UI"; // Windows: C:/Users/"User"/Documents/cemu_UI
public String dirLinux = userHome + "/cemu_UI"; // Linux: /home/"User"/cemu_UI
private File directory;
private File configFile;
private File gamesDBFile;
@SuppressWarnings("unused")
private File localDB;
private File pictureCache;
private static String dirCemuUI;
private static File directory;
private static File configFile;
private static File gamesDBFile;
private static File reference_gamesFile;
private static File pictureCache;
private static Logger LOGGER;
@Override
@ -80,7 +76,10 @@ public class Main extends Application {
LOGGER.info("OS: " + osName + " " + osVers + " " + osArch);
LOGGER.info("Java: " + javaVend + " " + javaVers);
LOGGER.info("User: " + userName + " " + userHome);
this.primaryStage = primaryStage;
mainWindowController = new MainWindowController(this);
mainWindow();
initActions();
} catch (Exception e) {
@ -93,31 +92,24 @@ public class Main extends Application {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(ClassLoader.getSystemResource("fxml/MainWindow.fxml"));
loader.setController(mainWindowController);
pane = (AnchorPane) loader.load();
primaryStage.setMinWidth(265.00);
primaryStage.setMinHeight(425.00);
primaryStage.setTitle("cemu_UI");
// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/resources/Homeflix_Icon_64x64.png"))); //adds application icon
mainWindowController = loader.getController(); // Link of FXMLController and controller class
mainWindowController.setMain(this); // call setMain
// primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream(""))); //adds application icon
primaryStage.setOnCloseRequest(event -> System.exit(1));
// generate window
scene = new Scene(pane); // create new scene, append pane to scene
scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm());
primaryStage.setScene(scene); // append scene to stage
primaryStage.show(); // show stage
cloudController = new CloudController(mainWindowController); // call cloudController constructor
// get OS and the specific paths
if (osName.equals("Linux")) {
directory = new File(dirLinux);
configFile = new File(dirLinux + "/config.xml");
gamesDBFile = new File(dirLinux + "/games.db");
localDB = new File(dirLinux+"/localRoms.db");
pictureCache= new File(dirLinux+"/picture_cache");
} else {
directory = new File(dirWin);
configFile = new File(dirWin + "/config.xml");
gamesDBFile = new File(dirWin + "/games.db");
localDB = new File(dirWin+"/localRoms.db");
pictureCache= new File(dirWin+"/picture_cache");
}
// startup checks
// check if client_secret.jason is present
// check if client_secret.json is present
if (Main.class.getResourceAsStream("/client_secret.json") == null) {
LOGGER.error("client_secret is missing!!!!!");
@ -139,22 +131,26 @@ public class Main extends Application {
firstStart();
mainWindowController.setColor("00a8cc");
mainWindowController.setAutoUpdate(false);
mainWindowController.setLanguage("en_US");
mainWindowController.setLastLocalSync(0);
mainWindowController.setxPosHelper(0);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}
if (pictureCache.exists() != true) {
if (!pictureCache.exists()) {
pictureCache.mkdir();
}
if (gamesDBFile.exists() != true) {
if (!reference_gamesFile.exists()) {
if (gamesDBFile.exists()) {
gamesDBFile.delete();
}
try {
LOGGER.info("downloading games.db... ");
LOGGER.info("downloading ReferenceGameList.db... ");
URL website = new URL(gamesDBdownloadURL);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(gamesDBFile);
FileOutputStream fos = new FileOutputStream(reference_gamesFile);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
LOGGER.info("finished downloading games.db");
@ -163,26 +159,44 @@ public class Main extends Application {
}
}
// loading settings and initialize UI, dbController.main() loads all databases
// init here as it loads the games to the mwc and the gui, therefore the window must exist
mainWindowController.init();
mainWindowController.dbController.main();
mainWindowController.getDbController().init();
// if cloud sync is activated start sync
if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
}
mainWindowController.addUIData();
scene = new Scene(pane); // create new scene, append pane to scene
scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm());
primaryStage.setScene(scene); // append scene to stage
primaryStage.show(); // show stage
} catch (IOException e) {
e.printStackTrace();
cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath());
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void firstStart(){
public static void main(String[] args) {
if (osName.contains("Windows")) {
dirCemuUI = userHome + "/Documents/cemu_UI";
} else {
dirCemuUI = userHome + "/cemu_UI";
}
directory = new File(dirCemuUI);
configFile = new File(dirCemuUI + "/config.xml");
gamesDBFile = new File(dirCemuUI + "/games.db");
reference_gamesFile = new File(dirCemuUI + "/reference_games.db");
pictureCache= new File(dirCemuUI+"/picture_cache");
// delete old log file and create new
System.setProperty("logFilename", dirCemuUI + "/app.log");
File logFile = new File(dirCemuUI + "/app.log");
logFile.delete();
LOGGER = LogManager.getLogger(Main.class.getName());
launch(args);
}
private void firstStart() {
Alert alert = new Alert(AlertType.CONFIRMATION); // new alert with file-chooser
alert.setTitle("cemu_UI");
alert.setHeaderText("cemu installation");
@ -206,11 +220,10 @@ public class Main extends Application {
Optional<ButtonType> result2 = alert2.showAndWait();
if (result2.get() == ButtonType.OK) {
DirectoryChooser directoryChooser = new DirectoryChooser();
File selectedDirectory = directoryChooser.showDialog(primaryStage);
mainWindowController.setRomPath(selectedDirectory.getAbsolutePath());
File selectedDirectory = directoryChooser.showDialog(primaryStage);
mainWindowController.setRomDirectoryPath(selectedDirectory.getAbsolutePath());
} else {
mainWindowController.setRomPath(null);
mainWindowController.setRomDirectoryPath(null);
}
}
@ -224,8 +237,6 @@ public class Main extends Application {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, final Number newValue) {
int xPosHelperMax = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217);
mainWindowController.refreshplayBtnPosition();
// call only if there is enough space for a new row
if (mainWindowController.getOldXPosHelper() != xPosHelperMax) {
@ -237,7 +248,7 @@ public class Main extends Application {
saveTask = new TimerTask() {
@Override
public void run() {
public void run() {
mainWindowController.saveSettings();
}
};
@ -258,7 +269,7 @@ public class Main extends Application {
saveTask = new TimerTask() {
@Override
public void run() {
public void run() {
mainWindowController.saveSettings();
}
};
@ -288,24 +299,48 @@ public class Main extends Application {
primaryStage.heightProperty().addListener(heightListener);
primaryStage.maximizedProperty().addListener(maximizeListener);
}
public static void main(String[] args) {
// delete old log file and create new
if(osName.equals("Linux")){
System.setProperty("logFilename", userHome + "/cemu_UI/app.log");
File logFile = new File(userHome + "/cemu_UI/app.log");
logFile.delete();
}else{
System.setProperty("logFilename", userHome + "/Documents/cemu_UI/app.log");
File logFile = new File(userHome + "/Documents/cemu_UI/app.log");
logFile.delete();
}
LOGGER = LogManager.getLogger(Main.class.getName());
launch(args);
public Stage getPrimaryStage() {
return primaryStage;
}
@Override
public void stop() {
System.exit(0);
public void setPrimaryStage(Stage primaryStage) {
this.primaryStage = primaryStage;
}
public CloudController getCloudController() {
return cloudController;
}
public void setCloudController(CloudController cloudController) {
this.cloudController = cloudController;
}
public AnchorPane getPane() {
return pane;
}
public void setPane(AnchorPane pane) {
this.pane = pane;
}
public File getDirectory() {
return directory;
}
public File getConfigFile() {
return configFile;
}
public File getGamesDBFile() {
return gamesDBFile;
}
public File getReference_gamesFile() {
return reference_gamesFile;
}
public File getPictureCache() {
return pictureCache;
}
}

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,33 +18,34 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.application;
import java.io.IOException;
import java.time.Instant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.cemu_UI.controller.dbController;
import com.cemu_UI.controller.DBController;
import javafx.application.Platform;
public class playGame extends Thread{
MainWindowController mainWindowController;
dbController dbController;
private MainWindowController mainWindowController;
private DBController dbController;
private static final Logger LOGGER = LogManager.getLogger(playGame.class.getName());
public playGame(MainWindowController m, com.cemu_UI.controller.dbController db){
public playGame(MainWindowController m, com.cemu_UI.controller.DBController db) {
mainWindowController = m;
dbController = db;
}
@Override
public void run(){
public void run() {
String selectedGameTitleID = mainWindowController.getSelectedGameTitleID();
String executeComand;
String cemuBin = mainWindowController.getCemuPath() + "/Cemu.exe";
String gameExec = "\"" + mainWindowController.getGameExecutePath() + "\"";
long startTime;
long endTime;
int timePlayedNow;
@ -52,51 +53,50 @@ public class playGame extends Thread{
Process p;
Platform.runLater(() -> {
mainWindowController.main.primaryStage.setIconified(true);
mainWindowController.getMain().getPrimaryStage().setIconified(true); // minimize cemu_UI
});
startTime = System.currentTimeMillis();
try{
if(mainWindowController.isFullscreen()){
if(System.getProperty("os.name").equals("Linux")){
executeComand = "wine "+mainWindowController.getCemuPath()+"/Cemu.exe -f -g \""+mainWindowController.getGameExecutePath()+"\"";
try {
if (System.getProperty("os.name").equals("Linux")) {
if(mainWindowController.isFullscreen()){
p = new ProcessBuilder("wine", cemuBin, "-f", "-g", gameExec).start();
} else {
executeComand = mainWindowController.getCemuPath()+"\\Cemu.exe -f -g \""+mainWindowController.getGameExecutePath()+"\"";
p = new ProcessBuilder("wine", cemuBin, "-g", gameExec).start();
}
}else{
if(System.getProperty("os.name").equals("Linux")){
executeComand = "wine "+mainWindowController.getCemuPath()+"/Cemu.exe -g \""+mainWindowController.getGameExecutePath()+"\"";
} else {
if(mainWindowController.isFullscreen()){
p = new ProcessBuilder(cemuBin, "-f", "-g", gameExec).start();
} else {
executeComand = mainWindowController.getCemuPath()+"\\Cemu.exe -g \""+mainWindowController.getGameExecutePath()+"\"";
p = new ProcessBuilder(cemuBin, "-g", gameExec).start();
}
}
LOGGER.info(executeComand);
}
p = Runtime.getRuntime().exec(executeComand);
p.waitFor();
p.waitFor(); // wait until cemu is closed so we can calculate the played time
endTime = System.currentTimeMillis();
timePlayedNow = (int) Math.floor(((endTime - startTime)/1000/60));
timePlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))+timePlayedNow;
dbController.setTotalPlaytime(Integer.toString(timePlayed), selectedGameTitleID);
Platform.runLater(() -> {
if(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) > 60){
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))/60);
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))-60*hoursPlayed;
mainWindowController.totalPlaytimeBtn.setText(hoursPlayed+"h "+minutesPlayed+"min");
}else{
mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID)+ " min");
}
mainWindowController.main.primaryStage.setIconified(false);
});
dbController.setTotalPlaytime(Integer.toString(timePlayed), selectedGameTitleID);
Platform.runLater(() -> {
if (Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) > 60) {
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) / 60);
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) - 60 * hoursPlayed;
mainWindowController.totalPlaytimeBtn.setText(hoursPlayed + "h " + minutesPlayed + "min");
} else {
mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID) + " min");
}
mainWindowController.getMain().getPrimaryStage().setIconified(false); // maximize cemu_UI
});
// System.out.println(mainWindowController.getCemuPath()+"/mlc01/emulatorSave/"+);
//sync savegame with cloud service
if(mainWindowController.isCloudSync()) {
mainWindowController.main.cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
}
if (mainWindowController.isCloudSync()) {
mainWindowController.setLastLocalSync(Instant.now().getEpochSecond());
mainWindowController.getMain().getCloudController().sync(mainWindowController.getCloudService(),
mainWindowController.getCemuPath(), mainWindowController.getMain().getDirectory().getPath());
}
}catch (IOException | InterruptedException e){
e.printStackTrace();
} catch (IOException | InterruptedException e) {
LOGGER.error(e);
}
}

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,11 +18,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.Instant;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -31,6 +35,8 @@ import com.cemu_UI.application.MainWindowController;
import com.cemu_UI.vendorCloudController.GoogleDriveController;
import javafx.application.Platform;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
public class CloudController {
@ -63,105 +69,144 @@ public class CloudController {
LOGGER.info("cloud initialisation done!");
return success;
}
public void stratupCheck(String cloudService, String cemuDirectory) {
if(cloudService.equals("GoogleDrive")) {
LOGGER.info("starting startup check google drive ...");
try {
if (!googleDriveController.checkFolder()) {
googleDriveController.creatFolder();
mwc.saveSettings();
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Platform.runLater(() -> {
mwc.getPlayBtn().setText("syncing...");
});
googleDriveController.uploadAllFiles();
Platform.runLater(() -> {
mwc.getPlayBtn().setText("play");
});
}
});
thread.start();
} else {
sync(cloudService, cemuDirectory);
}
} catch (IOException e) {
LOGGER.error("google drive startup check failed", e);
}
}
if(cloudService.equals("Dropbox")) {
}
}
public void sync(String cloudService, String cemuDirectory) {
//running sync in a new thread, instead of blocking the main thread
/**
* to trigger a new sync set the mwc LastLocalSync to the actual time and call the sync method
* @param cloudService
* @param cemuDirectory
* @param cemu_UIDirectory
*/
public void sync(String cloudService, String cemuDirectory, String cemu_UIDirectory) {
// running sync in a new thread, instead of blocking the main thread
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Platform.runLater(() -> {
mwc.getPlayBtn().setText("syncing...");
});
LOGGER.info("starting synchronization in new thread ...");
if(cloudService.equals("GoogleDrive")) {
try {
googleDriveController.sync(cemuDirectory);
} catch (IOException e) {
LOGGER.error("google drive synchronization failed", e);
}
}
if(cloudService.equals("Dropbox")) {
}
Platform.runLater(() -> {
mwc.getPlayBtn().setText("play");
mwc.saveSettings();
});
LOGGER.info("synchronization successful!");
}
});
thread.start();
}
void uploadFile(String cloudService, File file) {
//running uploadFile in a new thread, instead of blocking the main thread
new Thread() {
@Override
public void run() {
LOGGER.info("starting uploadFile in new thread ...");
if(cloudService.equals("GoogleDrive")) {
try {
googleDriveController.uploadFile(file);
} catch (IOException e) {
LOGGER.error("google drive uploadFile failed" ,e);
}
}
if(cloudService.equals("Dropbox")) {
try {
Platform.runLater(() -> {
mwc.getPlayBtn().setDisable(true);
mwc.getPlayBtn().setText("syncing...");
});
LOGGER.info("starting synchronization in new thread ...");
// zip the saves folder
File zipFile = zipSavegames(cemu_UIDirectory, cemuDirectory);
}
}
}.start();
// upload the zip
switch (cloudService) {
// use GoogleDriveController
case "GoogleDrive":
LOGGER.info("using GoogleDriveController");
long lastCloudSync = googleDriveController.getLastCloudSync();
if (!googleDriveController.checkFolder()) {
LOGGER.info("cloud sync folder dosen't exist, creating one!");
googleDriveController.creatFolder();
googleDriveController.uploadZipFile(zipFile);
} else if (mwc.getLastLocalSync() > lastCloudSync) {
LOGGER.info("local is new, going to upload zip");
googleDriveController.uploadZipFile(zipFile);
} else if(mwc.getLastLocalSync() < lastCloudSync) {
LOGGER.info("cloud is new, going to download zip");
unzipSavegames(cemuDirectory, googleDriveController.downloadZipFile(cemu_UIDirectory));
mwc.setLastLocalSync(lastCloudSync);
break;
} else {
LOGGER.info("nothing to do");
break;
}
mwc.setLastLocalSync(Long.parseLong(zipFile.getName().substring(0, zipFile.getName().length()-4))); // set time of last sucessfull sync
break;
case "Dropbox":
break;
default:
LOGGER.warn("no cloud vendor found!");
break;
}
zipFile.delete(); // delete zipfile in cem_UI directory
Platform.runLater(() -> {
mwc.getPlayBtn().setText("play");
mwc.getPlayBtn().setDisable(false);
mwc.saveSettings();
});
LOGGER.info("synchronization successful!");
} catch (Exception e) {
LOGGER.error("There was an error during syncronisation! Please open a new issue on the cemu_UI github page:", e);
}
}
});
thread.start();
}
private File zipSavegames(String cemu_UIDirectory, String cemuDirectory) throws Exception {
long unixTimestamp = Instant.now().getEpochSecond();
FileOutputStream fos = new FileOutputStream(cemu_UIDirectory + "/" + unixTimestamp + ".zip");
ZipOutputStream zos = new ZipOutputStream(fos);
addDirToZipArchive(zos, new File(cemuDirectory + "/mlc01/usr/save"), null);
zos.flush();
fos.flush();
zos.close();
fos.close();
return new File(cemu_UIDirectory + "/" + unixTimestamp + ".zip");
}
private static void addDirToZipArchive(ZipOutputStream zos, File fileToZip, String parrentDirectoryName) throws Exception {
if (fileToZip == null || !fileToZip.exists()) {
return;
}
String zipEntryName = fileToZip.getName();
if (parrentDirectoryName!=null && !parrentDirectoryName.isEmpty()) {
zipEntryName = parrentDirectoryName + "/" + fileToZip.getName();
}
if (fileToZip.isDirectory()) {
for (File file : fileToZip.listFiles()) {
addDirToZipArchive(zos, file, zipEntryName);
}
} else {
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream(fileToZip);
zos.putNextEntry(new ZipEntry(zipEntryName));
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}
zos.closeEntry();
fis.close();
}
}
private void unzipSavegames(String cemuDirectory, File outputFile) {
try {
ZipFile zipFile = new ZipFile(outputFile);
zipFile.extractAll(cemuDirectory + "/mlc01/usr");
outputFile.delete();
LOGGER.info("unzip successfull");
} catch (ZipException e) {
LOGGER.error("an error occurred during unziping the file!", e);
}
}
public String getFolderID(String cloudService) {
String folderID = "";
if (cloudService != null) {
if(cloudService.equals("GoogleDrive")) {
if (cloudService.equals("GoogleDrive")) {
folderID = googleDriveController.getFolderID();
}
if(cloudService.equals("Dropbox")) {
if (cloudService.equals("Dropbox")) {
}
}
return folderID;
@ -173,8 +218,9 @@ public class CloudController {
googleDriveController.setFolderID(folderID);
}
if (cloudService.equals("Dropbox")) {
}
}
}
}

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.controller;
import java.awt.Graphics2D;
@ -45,30 +44,36 @@ import org.apache.logging.log4j.Logger;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.cemu_UI.application.Main;
import com.cemu_UI.application.MainWindowController;
public class dbController {
public class DBController {
public dbController(MainWindowController m) {
mainWindowController = m;
public DBController(Main main, MainWindowController mainWindowController) {
this.main = main;
this.mainWindowController = mainWindowController;
}
private Main main;
private MainWindowController mainWindowController;
private ArrayList<String> entries = new ArrayList<>();
private String DB_PATH_localRoms;
private String DB_PATH_games;
private Connection connection = null;
private Connection connectionGames = null;
private static final Logger LOGGER = LogManager.getLogger(dbController.class.getName());
private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName());
public void main(){
LOGGER.info("<==========starting loading sql==========>");
/**
* initialize the sqlite database controller
* load ROM and games database
* load all games
*/
public void init() {
LOGGER.info("<========== starting loading sql ==========>");
loadRomDatabase();
loadGamesDatabase();
createRomDatabase();
loadAllGames();
checkRemoveEntry();
LOGGER.info("<==========finished loading sql==========>");
LOGGER.info("<========== finished loading sql ==========>");
}
/**
@ -76,18 +81,18 @@ public class dbController {
*
* TODO this should be called LocalGames
*/
private void loadRomDatabase(){
private void loadRomDatabase() {
if (System.getProperty("os.name").equals("Linux")) {
DB_PATH_localRoms = System.getProperty("user.home") + "/cemu_UI/localRoms.db";
}else{
} else {
DB_PATH_localRoms = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "localRoms.db";
}
try {
// create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_localRoms);
connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active
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
// if the error message is "out of memory", probably no database file is found
LOGGER.error("error while loading the ROM database", e);
}
LOGGER.info("ROM database loaded successfull");
@ -95,16 +100,10 @@ public class dbController {
/**
* set the path to the localRoms.db file and initialize the connection
*
* games.dbcontains a reverence list to for the automatic detection mode
* TODO this should be called ReferenceGameList the games table should be called reference_games
* games.db contains a reverence list to for the automatic detection mode
*/
private void loadGamesDatabase() {
if (System.getProperty("os.name").equals("Linux")) {
DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/games.db";
} else {
DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "games.db";
}
DB_PATH_games = main.getReference_gamesFile().getAbsolutePath();
try {
// create a database connection
connectionGames = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_games);
@ -144,11 +143,14 @@ public class dbController {
LOGGER.error("error while loading ROMs from ROM database, local_roms table", e);
}
if (entries.size() == 0) {
loadRomDirectory(mainWindowController.getRomPath());
mainWindowController.reloadRoms();
} else {
loadAllGames();
mainWindowController.refreshUIData();
}
}
// add a Ggame to the database
// add a game to the database
public void addGame(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+"',"
@ -158,6 +160,7 @@ public class dbController {
LOGGER.info("added \""+title+"\" to ROM database");
}
// remove a game from the database
public void removeGame(String titleID) throws SQLException{
Statement stmt = connection.createStatement();
stmt.executeUpdate("delete from local_roms where titleID = '"+titleID+"'");
@ -166,8 +169,8 @@ public class dbController {
LOGGER.info("removed \""+titleID+"\" from ROM database");
}
//load all ROMs on startup to the mainWindowController
void loadAllGames(){
//load all ROMs to the mainWindowController
public void loadAllGames(){
LOGGER.info("loading all games on startup into the mainWindowController ...");
try {
Statement stmt = connection.createStatement();
@ -182,7 +185,7 @@ public class dbController {
}
}
//load one single ROM after manual adding into the mainWindowController
//load a single ROM to the mainWindowController
public void loadSingleGame(String titleID){
LOGGER.info("loading a single game (ID: "+titleID+") into the mainWindowController ...");
try {
@ -206,61 +209,55 @@ public class dbController {
File dir = new File(directory);
File appFile;
String[] extensions = new String[] { "rpx", "jsp" };
File pictureCache;
String coverPath;
if(System.getProperty("os.name").equals("Linux")){
pictureCache = mainWindowController.getPictureCacheLinux();
}else{
pictureCache = mainWindowController.getPictureCacheWin();
}
File pictureCache = main.getPictureCache();
String coverPath;
try {
Statement stmt = connectionGames.createStatement();
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
LOGGER.info("<============================== start loading ROM Directory ==============================>");
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
// for all files in dir get the app.xml
for (File file : files) {
if(System.getProperty("os.name").equals("Linux")){
appFile = new File(file.getParent()+"/app.xml");
} else {
appFile = new File(file.getParent()+"\\app.xml");
}
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(); //get titile_ID from app.xml
String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); // get titile_ID from app.xml
title_ID = title_ID.substring(0, 8) + "-" + title_ID.substring(8, title_ID.length());
LOGGER.info("Name: "+file.getName()+"; Title ID: "+title_ID);
ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '"+title_ID+"';");
LOGGER.info("Name: " + file.getName() + "; Title ID: " + title_ID);
ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '" + title_ID + "';");
// for all elements in the games table check if it's already present, else add it
while (rs.next()) {
if (checkEntry(rs.getString(2))) {
if (checkAddEntry(rs.getString(2))) {
LOGGER.info(rs.getString(2) + ": game already in database");
}else{
} else {
LOGGER.info("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);
if(System.getProperty("os.name").equals("Linux")) {
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"/"+rs.getString(3)+".png")); //change path where you want it saved
coverPath = pictureCache+"/"+rs.getString(3)+".png";
} else {
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+rs.getString(3)+".png")); //change path where you want it saved
coverPath = pictureCache+"\\"+rs.getString(3)+".png";
}
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"));
coverPath = pictureCache + "/" + rs.getString(3) + ".png";
LOGGER.info(rs.getString(2) + ": adding ROM");
addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), rs.getString(5),"","0");
addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3),
rs.getString(5), "", "0");
}
}
}
LOGGER.info("<============================= finished loading ROM Directory ============================>");
} catch (IOException | SQLException | ParserConfigurationException | SAXException e) {
LOGGER.error("error while loading ROMs from directory", e);
}
}
private boolean checkEntry(String title) throws SQLException{
/**
* check if there is a game with the given name already in the database
* @param title game title
* @return true if the game exists, false if not
* @throws SQLException
*/
private boolean checkAddEntry(String title) throws SQLException{
Statement stmt = connection.createStatement();
boolean check = false;
ResultSet rs = stmt.executeQuery("SELECT * FROM local_roms WHERE title = '"+title+"';");
@ -270,6 +267,7 @@ public class dbController {
return check;
}
@SuppressWarnings("unused")
private void checkRemoveEntry() {
/**
* TODO needs to be implemented!

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.controller;
import java.io.BufferedReader;

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.controller;
import java.io.BufferedReader;
@ -40,7 +39,6 @@ import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue;
import javafx.application.Platform;
public class UpdateController implements Runnable {
@ -49,16 +47,18 @@ public class UpdateController implements Runnable {
private String buildNumber;
private String apiOutput;
private String updateBuildNumber; // tag_name from Github
// private String updateName;
// private String updateChanges;
private String browserDownloadUrl; // update download link
private String githubApiRelease = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest";
private String githubApiBeta = "https://api.github.com/repos/Seil0/cemu_UI/releases";
private URL githubApiUrl;
private boolean useBeta;
private static final Logger LOGGER = LogManager.getLogger(UpdateController.class.getName());
/**
* updater for cemu_UI based on Project HomeFlix checks for Updates and download
* it in case there is one
* updater for cemu_UI, checks for Updates and download it
*/
public UpdateController(MainWindowController mwc, String buildNumber, boolean useBeta) {
mainWindowController = mwc;
@ -70,7 +70,7 @@ public class UpdateController implements Runnable {
public void run() {
LOGGER.info("beta:" + useBeta + "; checking for updates ...");
Platform.runLater(() -> {
mainWindowController.getUpdateBtn().setText("checking for updates ...");
mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnChecking"));
});
try {
@ -97,8 +97,8 @@ public class UpdateController implements Runnable {
JsonArray objectAssets = object.asObject().get("assets").asArray();
updateBuildNumber = object.asObject().getString("tag_name", "");
// updateName = object.asObject().getString("name", "");
// updateChanges = object.asObject().getString("body", "");
// updateName = object.asObject().getString("name", "");
// updateChanges = object.asObject().getString("body", "");
for (JsonValue asset : objectAssets) {
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");
@ -109,8 +109,8 @@ public class UpdateController implements Runnable {
JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray();
updateBuildNumber = object.getString("tag_name", "");
// updateName = object.getString("name", "");
// updateChanges = object.getString("body", "");
// updateName = object.getString("name", "");
// updateChanges = object.getString("body", "");
for (JsonValue asset : objectAssets) {
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");
@ -126,28 +126,28 @@ public class UpdateController implements Runnable {
if (iversion >= iaktVersion) {
Platform.runLater(() -> {
mainWindowController.getUpdateBtn().setText("no update available");
mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnNoUpdateAvailable"));
});
LOGGER.info("no update available");
} else {
Platform.runLater(() -> {
mainWindowController.getUpdateBtn().setText("update available");
mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnUpdateAvailable"));
});
LOGGER.info("update available");
LOGGER.info("download link: " + browserDownloadUrl);
try {
// open new Http connection, ProgressMonitorInputStream for downloading the data
HttpURLConnection conn = (HttpURLConnection) new URL(browserDownloadUrl).openConnection();
ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", conn.getInputStream());
HttpURLConnection connection = (HttpURLConnection) new URL(browserDownloadUrl).openConnection();
ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", connection.getInputStream());
ProgressMonitor pm = pmis.getProgressMonitor();
pm.setMillisToDecideToPopup(0);
pm.setMillisToPopup(0);
pm.setMinimum(0);// tell the progress bar that we start at the beginning of the stream
pm.setMaximum(conn.getContentLength());// tell the progress bar the total number of bytes we are going to read.
pm.setMinimum(0);// set beginning of the progress bar to 0
pm.setMaximum(connection.getContentLength());// set the end to the file length
FileUtils.copyInputStreamToFile(pmis, new File("cemu_UI_update.jar")); // download update
org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar")); // TODO rename update to old name
org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar"));
org.apache.commons.io.FileUtils.deleteQuietly(new File("cemu_UI_update.jar")); // delete update
Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again
new ProcessBuilder("java", "-jar", "cemu_UI.jar").start(); // start the new application
System.exit(0); // finishes itself
} catch (IOException e) {
Platform.runLater(() -> {

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.datatypes;
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.datatypes;
import javafx.beans.property.IntegerProperty;

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.datatypes;
import com.jfoenix.controls.JFXButton;

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.uiElements;
import java.io.File;
@ -88,18 +86,15 @@ public class JFXEditGameDialog {
StackPane stackPane = new StackPane();
stackPane.autosize();
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
Label placeholder = new Label();
placeholder.setPrefSize(15, 10);
TextField gameTitleTF = new TextField();
gameTitleTF.setPromptText("game tile");
gameTitleTF.setPromptText(mwc.getBundle().getString("gameTitle"));
TextField gameTitleIDTF = new TextField();
gameTitleIDTF.setPromptText("title ID");
gameTitleIDTF.setPromptText(mwc.getBundle().getString("titleID"));
TextField romPathTF = new TextField();
romPathTF.setPromptText("ROM path");
romPathTF.setPromptText(mwc.getBundle().getString("romPath"));
TextField gameCoverTF = new TextField();
gameCoverTF.setPromptText("cover path");
gameCoverTF.setPromptText(mwc.getBundle().getString("coverPath"));
if (mode == 1) {
gameTitleTF.setText(title);
@ -110,7 +105,7 @@ public class JFXEditGameDialog {
gameTitleIDTF.setEditable(false);
}
JFXButton okayBtn = new JFXButton("Okay");
JFXButton okayBtn = new JFXButton(mwc.getBundle().getString("okayBtnText"));
okayBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
@ -120,11 +115,10 @@ public class JFXEditGameDialog {
// LOGGER.info("No parameter set!");
// addGame error dialog
String headingTextError = "Error while adding a new Game!";
String bodyTextError = "There was some truble adding your game."
+ "\nOne of the needed values was empty, please try again to add your game.";
JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350,170, pane);
errorDialog.show();
String headingTextError = mwc.getBundle().getString("editGameDialogHeadingTextError");
String bodyTextError = mwc.getBundle().getString("editGameDialogBodyTextError");
JFXInfoAlert errorDialog = new JFXInfoAlert(headingTextError, bodyTextError, dialogBtnStyle, stage);
errorDialog.showAndWait();
} else {
switch (mode) {
case 0:
@ -150,7 +144,7 @@ public class JFXEditGameDialog {
okayBtn.setPrefHeight(32);
okayBtn.setStyle(dialogBtnStyle);
JFXButton cancelBtn = new JFXButton("Cancel");
JFXButton cancelBtn = new JFXButton(mwc.getBundle().getString("cancelBtnText"));
cancelBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
@ -161,7 +155,7 @@ public class JFXEditGameDialog {
cancelBtn.setPrefHeight(32);
cancelBtn.setStyle(dialogBtnStyle);
JFXButton selectPathBtn = new JFXButton("select .rpx file");
JFXButton selectPathBtn = new JFXButton(mwc.getBundle().getString("editGameDialogSelectPathBtn"));
selectPathBtn.setPrefWidth(110);
selectPathBtn.setStyle(dialogBtnStyle);
selectPathBtn.setOnAction(new EventHandler<ActionEvent>() {
@ -173,7 +167,7 @@ public class JFXEditGameDialog {
}
});
JFXButton selectCoverBtn = new JFXButton("select cover file");
JFXButton selectCoverBtn = new JFXButton(mwc.getBundle().getString("editGameDialogSelectCoverBtn"));
selectCoverBtn.setPrefWidth(110);
selectCoverBtn.setStyle(dialogBtnStyle);
selectCoverBtn.setOnAction(new EventHandler<ActionEvent>() {
@ -189,14 +183,14 @@ public class JFXEditGameDialog {
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(15, 10, 10, 10));
grid.add(new Label("game title:"), 0, 0);
grid.add(new Label(mwc.getBundle().getString("gameTitle") + ":"), 0, 0);
grid.add(gameTitleTF, 1, 0);
grid.add(new Label("title id:"), 0, 1);
grid.add(new Label(mwc.getBundle().getString("titleID") + ":"), 0, 1);
grid.add(gameTitleIDTF, 1, 1);
grid.add(new Label("ROM path:"), 0, 2);
grid.add(new Label(mwc.getBundle().getString("romPath") + ":"), 0, 2);
grid.add(romPathTF, 1, 2);
grid.add(selectPathBtn, 2, 2);
grid.add(new Label("cover path:"), 0, 3);
grid.add(new Label(mwc.getBundle().getString("coverPath") + ":"), 0, 3);
grid.add(gameCoverTF, 1, 3);
grid.add(selectCoverBtn, 2, 3);
@ -207,7 +201,7 @@ public class JFXEditGameDialog {
content.setHeading(new Text(headingText));
content.setBody(vbox);
content.setActions(cancelBtn, placeholder, okayBtn);
content.setActions(cancelBtn, okayBtn);
content.setPrefSize(dialogWidth, dialogHeight);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2);

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
* Kellerkinder Framework Alerts
*
* Copyright 2017 <@Seil0>
* Copyright 2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,69 +18,94 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.uiElements;
import com.jfoenix.controls.JFXAlert;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialog;
import com.jfoenix.controls.JFXDialogLayout;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class JFXInfoDialog {
public class JFXInfoAlert {
private String headingText;
private String bodyText;
private String dialogBtnStyle;
private int dialogWidth;
private int dialogHeight;
private Pane pane;
private String btnStyle;
private Stage stage;
/**
* Creates a new JFoenix Dialog to show some information
* @param headingText Heading Text, just the heading
* @param bodyText body Text, all other text belongs here
* @param dialogBtnStyle Style of the okay button
* @param dialogWidth dialog width
* @param dialogHeight dialog height
* @param pane pane to which the dialog belongs
* Creates a new JFoenix Alert to show some information
* @param headerText Heading text of the alert
* @param bodyText Content text of the alert
* @param btnStyle Style of the okay button
* @param stage stage to which the dialog belongs
*/
public JFXInfoDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, int dialogHeight, Pane pane) {
this.headingText = headingText;
this.bodyText = bodyText;
this.dialogBtnStyle = dialogBtnStyle;
this.dialogWidth = dialogWidth;
this.dialogHeight = dialogHeight;
this.pane = pane;
public JFXInfoAlert(String headingText, String bodyText, String btnStyle, Stage stage) {
setHeadingText(headingText);
setBodyText(bodyText);
setBtnStyle(btnStyle);
setStage(stage);
}
public void show() {
JFXDialogLayout content = new JFXDialogLayout();
content.setHeading(new Text(headingText));
content.setBody(new Text(bodyText));
content.setPrefSize(dialogWidth, dialogHeight);
StackPane stackPane = new StackPane();
stackPane.autosize();
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
public JFXInfoAlert() {
// Auto-generated constructor stub
}
public void showAndWait( ) {
JFXAlert<Void> alert = new JFXAlert<>(stage);
JFXButton button = new JFXButton("Okay");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
dialog.close();
alert.close();
}
});
button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
button.setPrefHeight(32);
button.setStyle(dialogBtnStyle);
button.setStyle(btnStyle);
JFXDialogLayout content = new JFXDialogLayout();
content.setActions(button);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2);
AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2);
dialog.show();
content.setHeading(new Text(headingText));
content.setBody(new Text(bodyText));
alert.setContent(content);
alert.showAndWait();
}
}
public String getHeadingText() {
return headingText;
}
public void setHeadingText(String headingText) {
this.headingText = headingText;
}
public String getBodyText() {
return bodyText;
}
public void setBodyText(String bodyText) {
this.bodyText = bodyText;
}
public String getBtnStyle() {
return btnStyle;
}
public void setBtnStyle(String btnStyle) {
this.btnStyle = btnStyle;
}
public Stage getStage() {
return stage;
}
public void setStage(Stage stage) {
this.stage = stage;
}
}

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,17 +18,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.uiElements;
import java.util.ResourceBundle;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialog;
import com.jfoenix.controls.JFXDialogLayout;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
@ -39,8 +38,8 @@ public class JFXOkayCancelDialog {
private String headingText;
private String bodyText;
private String dialogBtnStyle;
private String okayText = "okay";
private String cancelText = "cancel";
private String okayText;
private String cancelText;
private int dialogWidth;
private int dialogHeight;
private EventHandler<ActionEvent> okayAction;
@ -59,7 +58,8 @@ public class JFXOkayCancelDialog {
* @param pane pane to which the dialog belongs
*/
public JFXOkayCancelDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth,
int dialogHeight, EventHandler<ActionEvent> okayAction, EventHandler<ActionEvent> cancelAction, Pane pane) {
int dialogHeight, EventHandler<ActionEvent> okayAction, EventHandler<ActionEvent> cancelAction, Pane pane,
ResourceBundle bundle) {
this.headingText = headingText;
this.bodyText = bodyText;
this.dialogBtnStyle = dialogBtnStyle;
@ -68,9 +68,12 @@ public class JFXOkayCancelDialog {
this.okayAction = okayAction;
this.cancelAction = cancelAction;
this.pane = pane;
okayText = bundle.getString("okayBtnText");
cancelText = bundle.getString("cancelBtnText");
}
public void show() {
JFXDialogLayout content = new JFXDialogLayout();
content.setHeading(new Text(headingText));
content.setBody(new Text(bodyText));
@ -93,9 +96,7 @@ public class JFXOkayCancelDialog {
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
cancelBtn.setPrefHeight(32);
cancelBtn.setStyle(dialogBtnStyle);
Label placeholder = new Label();
placeholder.setPrefSize(15, 10);
content.setActions(cancelBtn, placeholder, okayBtn);
content.setActions(cancelBtn, okayBtn);
content.setPrefSize(dialogWidth, dialogHeight);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2);

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.uiElements;
import com.jfoenix.controls.JFXButton;

View File

@ -1,7 +1,7 @@
/**
* cemu_UI
*
* Copyright 2017 <@Seil0>
* Copyright 2017-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,20 +18,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.cemu_UI.vendorCloudController;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -56,15 +50,11 @@ import com.google.api.services.drive.model.FileList;
public class GoogleDriveController {
Drive service;
private String saveDirectory;
private String folderID;
private ArrayList<java.io.File> localSavegames = new ArrayList<>();
private ArrayList<File> cloudSavegames = new ArrayList<>();
private ArrayList<String> localSavegamesName = new ArrayList<>();
private ArrayList<String> cloudSavegamesName = new ArrayList<>();
private File downloadFile;
private static final Logger LOGGER = LogManager.getLogger(GoogleDriveController.class.getName());
private final String APPLICATION_NAME ="cemu_Ui Drive API Controller"; //TODO add Google
private final String APPLICATION_NAME ="cemu_Ui Google Drive API Controller";
//Directory to store user credentials for this application
private final java.io.File DATA_STORE_DIR = new java.io.File(System.getProperty("user.home"), ".credentials/cemu_UI_credential");
@ -125,69 +115,15 @@ public class GoogleDriveController {
.build();
}
public void main(String cemuDirectory) throws IOException {
java.io.File dir = new java.io.File(cemuDirectory + "/mlc01/usr/save");
service = getDriveService();
// cemu >= 1.11 uses /mlc01/usr/save/... instead of /mlc01/emulatorSave/...
if (dir.exists()) {
LOGGER.info("using new save path");
saveDirectory = cemuDirectory + "/mlc01/usr/save";
} else {
LOGGER.info("using old save path");
saveDirectory = cemuDirectory + "/mlc01/emulatorSave";
}
}
public void sync(String cemuDirectory) throws IOException {
//in case there is no folderID saved, look it up first
public void main(String cemuDirectory) throws IOException {
service = getDriveService();
if (getFolderID() == "" || getFolderID() == null) {
getSavegamesFolderID();
}
getLocalSavegames();
getCloudSavegames();
// download files from cloud which don't exist locally
for (int i = 0; i < cloudSavegames.size(); i++) {
// if the file exists locally, check which one is newer
if (localSavegamesName.contains(cloudSavegames.get(i).getName())) {
int localSavegamesNumber = localSavegamesName.indexOf(cloudSavegames.get(i).getName());
long localModified = new DateTime(localSavegames.get(localSavegamesNumber).lastModified()).getValue();
long cloudModified = cloudSavegames.get(i).getModifiedTime().getValue();
FileInputStream fis = new FileInputStream(localSavegames.get(localSavegamesNumber));
if (cloudSavegames.get(i).getMd5Checksum().equals(org.apache.commons.codec.digest.DigestUtils.md5Hex(fis))) {
LOGGER.info("both files are the same, nothing to do");
} else {
if (localModified >= cloudModified) {
LOGGER.info("local is newer");
updateFile(cloudSavegames.get(i), localSavegames.get(localSavegamesNumber));
} else {
LOGGER.info("cloud is newer");
downloadFile(cloudSavegames.get(i));
}
}
} else {
LOGGER.info("file doesn't exist locally");
downloadFile(cloudSavegames.get(i));
}
}
// upload file to cloud which don't exist in the cloud
for (int j = 0; j < localSavegames.size(); j++) {
if (!cloudSavegamesName.contains(localSavegamesName.get(j))) {
LOGGER.info("file doesn't exist in the cloud");
uploadFile(localSavegames.get(j));
}
}
}
//create a folder in google drive
// create a folder in google drive
public void creatFolder() throws IOException {
LOGGER.info("creating new folder");
File fileMetadata = new File();
@ -199,8 +135,8 @@ public class GoogleDriveController {
folderID = file.getId();
}
//check if folder already exist
public boolean checkFolder() {
// check if folder already exist
public boolean checkFolder() {
try {
Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'");
FileList files = request.execute();
@ -215,32 +151,58 @@ public class GoogleDriveController {
}
}
//reading all local savegames
private void getLocalSavegames() throws IOException {
java.io.File dir = new java.io.File(saveDirectory);
String[] extensions = new String[] { "dat","sav","bin" };
localSavegames.removeAll(localSavegames);
localSavegamesName.removeAll(localSavegamesName);
LOGGER.info("Getting all dat,sav,bin files in " + dir.getCanonicalPath()+" including those in subdirectories");
List<java.io.File> files = (List<java.io.File>) FileUtils.listFiles(dir, extensions, true);
for (java.io.File file : files) {
localSavegamesName.add(file.getParentFile().getName()+"_"+file.getName());
localSavegames.add(file);
}
}
//reading all cloud savegames
private void getCloudSavegames() throws IOException {
LOGGER.info("getting all cloud savegames");
cloudSavegames.removeAll(cloudSavegames);
cloudSavegamesName.removeAll(cloudSavegamesName);
// FIXME it seams like there is a bug in this method
// get the name of the zip in the semu_savegames folder, which is the last upload Unix time
public long getLastCloudSync() throws IOException {
LOGGER.info("getting last cloud sync");
long lastCloudSync = 0;
Files.List request = service.files().list().setQ("'"+folderID+"' in parents").setFields("nextPageToken, files(id, name, size, modifiedTime, createdTime, md5Checksum)");
FileList files = request.execute();
for (File file : files.getFiles()) {
cloudSavegamesName.add(file.getName());
cloudSavegames.add(file);
downloadFile = file;
lastCloudSync = Long.parseLong(file.getName().substring(0, file.getName().length()-4));
}
return lastCloudSync;
}
/**
* delete all existing files in cemu_savegames at first
* upload the new savegames zip file
* @param uploadFile savegames zip file
* @throws IOException
*/
public void uploadZipFile(java.io.File uploadFile) throws IOException{
LOGGER.info("deleting old savegames ...");
Files.List request = service.files().list().setQ("'"+folderID+"' in parents").setFields("nextPageToken, files(id, name, size, modifiedTime, createdTime, md5Checksum)");
FileList files = request.execute();
for (File file : files.getFiles()) {
service.files().delete(file.getId()).execute(); // deleting old file
}
LOGGER.info("uploading " + uploadFile.getName() + " ...");
File fileMetadata = new File();
fileMetadata.setName(uploadFile.getName());
fileMetadata.setParents(Collections.singletonList(folderID));
fileMetadata.setModifiedTime(new DateTime(uploadFile.lastModified()));
FileContent mediaContent = new FileContent("", uploadFile);
File file = service.files().create(fileMetadata, mediaContent).setFields("id, parents").execute();
LOGGER.info("upload successfull, File ID: " + file.getId());
}
// download zip file from the cloud and unzip it
public java.io.File downloadZipFile(String cemu_UIDirectory) throws IOException{
LOGGER.info("downloading "+downloadFile.getName()+" ...");
java.io.File outputFile = new java.io.File(cemu_UIDirectory + "/" + downloadFile.getName());
OutputStream outputStream = new FileOutputStream(outputFile);
service.files().get(downloadFile.getId()).executeMediaAndDownloadTo(outputStream);
outputStream.close();
LOGGER.info("download successfull: " + downloadFile.getName());
return outputFile;
}
private void getSavegamesFolderID() throws IOException {
@ -253,72 +215,14 @@ public class GoogleDriveController {
} catch (Exception e) {
LOGGER.error("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!", e);
}
}
}
//upload a file to the cloud from the local savegames folder
public void uploadFile(java.io.File uploadFile) throws IOException{
LOGGER.info("uploading " + uploadFile.getName() + " ...");
File fileMetadata = new File();
fileMetadata.setName(uploadFile.getParentFile().getName()+"_"+uploadFile.getName());
fileMetadata.setParents(Collections.singletonList(folderID));
fileMetadata.setModifiedTime(new DateTime(uploadFile.lastModified()));
FileContent mediaContent = new FileContent("", uploadFile);
File file = service.files().create(fileMetadata, mediaContent).setFields("id, parents").execute();
LOGGER.info("upload successfull, File ID: " + file.getId());
}
//download a file from the cloud to the local savegames folder
private void downloadFile(File downloadFile) throws IOException{
LOGGER.info("downloading "+downloadFile.getName()+" ...");
java.io.File directory = new java.io.File(saveDirectory + "/" + downloadFile.getName().substring(0,8));
String file = downloadFile.getName().substring(9,downloadFile.getName().length());
if(!directory.exists()) {
LOGGER.info("dir dosent exist");
directory.mkdir();
}
OutputStream outputStream = new FileOutputStream(directory +"/"+ file);
service.files().get(downloadFile.getId()).executeMediaAndDownloadTo(outputStream);
outputStream.close();
LOGGER.info("download successfull, File ID: " + file); //TODO add FileID
}
//update a file in the cloud, by deleting the old one and uploading an new with the same id
private void updateFile(File oldFile, java.io.File newFile) throws IOException {
LOGGER.info("updating " +oldFile.getName()+" ...");
service.files().delete(oldFile.getId()).execute(); //deleting old file
//uploading new file
File fileMetadata = new File();
fileMetadata.setName(newFile.getParentFile().getName()+"_"+newFile.getName());
fileMetadata.setParents(Collections.singletonList(folderID));
fileMetadata.setModifiedTime(new DateTime(newFile.lastModified()));
FileContent mediaContent = new FileContent("", newFile);
File file = service.files().create(fileMetadata, mediaContent).setFields("id, parents").execute();
LOGGER.info("update successfull, File ID: " + file.getId());
}
public void uploadAllFiles() {
try {
getLocalSavegames();
LOGGER.info("uploading " + localSavegames.size() + " files ...");
for (int i = 0; i < localSavegames.size(); i++) {
uploadFile(localSavegames.get(i));
}
LOGGER.info("finished uploading all files");
} catch (IOException e) {
LOGGER.error("error while uploading all files", e);
}
}
public String getFolderID() {
return folderID;
}
public void setFolderID(String folderID) {
this.folderID = folderID;
}
}
}

View File

@ -81,6 +81,38 @@
-fx-background-color: -fx-tree-table-color, -fx-box-border, -fx-control-inner-background;
-fx-background-insets: -1.4, 0, 1;
-fx-background-radius: 1.4, 0, 0;
/*....*/
-fx-padding: 1; /* 0.083333em; */
}
}
/*
* ChoiceBox
*/
.choice-box {
-fx-background-color: transparent;
-fx-border-color: #000000;
-fx-border-width: 0 0 1 0;
-fx-background-radius: 0;
-fx-border-radius: 0;
}
.choice-box:focused {
-fx-border-color: #9E9E9E;
}
.choice-box>.open-button>.arrow {
-fx-background-color: #757575;
}
.menu-item:focused {
-fx-background-color: #00A8CC;
}
/*
* Spinner
*/
.spinner {
-fx-background-color: #f4f4f4;
}

View File

@ -18,7 +18,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.TextFlow?>
<AnchorPane fx:id="mainAnchorPane" prefHeight="600.0" prefWidth="904.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cemu_UI.application.MainWindowController">
<AnchorPane fx:id="mainAnchorPane" minHeight="405.0" minWidth="260.0" prefHeight="600.0" prefWidth="904.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ScrollPane fx:id="mainScrollPane" fitToWidth="true" layoutY="38.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<content>
@ -91,12 +91,12 @@
<Insets left="-14.0" />
</padding>
</VBox>
<VBox spacing="10.0">
<VBox spacing="7.0">
<children>
<Label fx:id="cemuDirectoryLbl" text="Cemu Directory" />
<HBox spacing="10.0">
<children>
<JFXTextField fx:id="cemuTextField" maxWidth="305.0" minWidth="305.0" onAction="#cemuTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" />
<JFXTextField fx:id="cemuTextField" maxWidth="305.0" minWidth="305.0" prefHeight="32.0" prefWidth="305.0" promptText="cemu directory" />
<JFXButton fx:id="cemuTFBtn" onAction="#cemuTFBtnAction" prefHeight="32.0" text="choose directory" />
</children>
</HBox>
@ -105,12 +105,12 @@
<Insets right="5.0" />
</padding>
</VBox>
<VBox spacing="10.0">
<VBox spacing="7.0">
<children>
<Label fx:id="romDirectoryLbl" text="Rom Directory" />
<HBox spacing="10.0">
<children>
<JFXTextField fx:id="romTextField" maxWidth="305.0" minWidth="305.0" onAction="#romTextFieldAction" prefHeight="32.0" prefWidth="305.0" promptText="rom directory" />
<JFXTextField fx:id="romTextField" maxWidth="305.0" minWidth="305.0" prefHeight="32.0" prefWidth="305.0" promptText="rom directory" />
<JFXButton fx:id="romTFBtn" onAction="#romTFBtnAction" prefHeight="32.0" text="choose directory" />
</children>
</HBox>
@ -118,10 +118,16 @@
</VBox>
<HBox spacing="10.0">
<children>
<Label fx:id="mainColorLbl" prefHeight="25.0" text="main Color" />
<Label fx:id="mainColorLbl" minHeight="25.0" text="main Color" />
<JFXColorPicker fx:id="colorPicker" onAction="#colorPickerAction" />
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0">
<children>
<Label fx:id="languageLbl" prefHeight="25.0" text="language" />
<ChoiceBox fx:id="languageChoisBox" prefWidth="150.0" />
</children>
</HBox>
<JFXToggleButton fx:id="cloudSyncToggleBtn" onAction="#cloudSyncToggleBtnAction" text="cloud savegames (Google Drive)" />
<VBox spacing="10.0">
<children>
@ -205,13 +211,17 @@
</ScrollPane>
</children>
</AnchorPane>
<JFXButton fx:id="playBtn" buttonType="RAISED" layoutX="396.0" maxHeight="28.0" minWidth="100.0" onAction="#playBtnAction" ripplerFill="#00aacc" text="play" textAlignment="CENTER" visible="false" AnchorPane.bottomAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
<HBox fx:id="bottomHBox" alignment="CENTER" layoutX="326.0" layoutY="602.0" prefHeight="48.0" prefWidth="200.0" spacing="10.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" maxHeight="32.0" maxWidth="156.0" minHeight="32.0" minWidth="156.0" onAction="#totalPlaytimeBtnAction" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="0 h 0 min">
</JFXButton>
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" layoutX="275.5" maxHeight="32.0" minWidth="100.0" onAction="#totalPlaytimeBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="0 h 0 min" visible="false" AnchorPane.bottomAnchor="10.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" layoutX="516.5" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="Last played, never" visible="false" AnchorPane.bottomAnchor="10.0" />
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="28.0" minWidth="100.0" onAction="#playBtnAction" ripplerFill="#00aacc" text="play" textAlignment="CENTER">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" maxWidth="156.0" minHeight="32.0" minWidth="156.0" onAction="#lastTimePlayedBtnAction" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" text="Last played, never" />
</children>
</HBox>
</children>
</AnchorPane>

View File

@ -0,0 +1,87 @@
#HomeFlix-Local_de_DE.properties DE-Deutsch Local
# Buttons
aboutBtn = \u00dcber
settingsBtn = Einstellungen
addBtn = Spiel hinzuf\u00fcgen
reloadRomsBtn = ROMs neu laden
smmdbBtn = smmdb
cemuTFBtn = Ordner \u00F6ffnen
romTFBtn = Ordner \u00F6ffnen
smmdbDownloadBtn = Download
playBtn = spielen
cloudSyncToggleBtn = Spielst\u00e4nde \u00fcber die Cloud syncronisieren (Google Drive)
autoUpdateToggleBtn = beim Start nach Updates suchen
fullscreenToggleBtn = Spiel im Vollbildmodus starten
# Labels
cemu_UISettingsLbl = cemu_UI Einstellungen
cemuDirectoryLbl = cemu directory
romDirectoryLbl = ROM directory
mainColorLbl = Hauptfarbe
languageLbl = Sprache
updateLbl = updates
branchLbl = Updatezweig
cemuSettingsLbl = cemu Einstellungen
licensesLbl = Lizenzen
# Columns
titleColumn = Titel
idColumn = ID
starsColumn = Sterne
timeColumn = Zeit
# Strings
editHeadingText = bearbeiten
editBodyText = Du kannst den Title und den ROM-/Coverpfad bearbeiten.
removeHeadingText = löschen
removeBodyText = Bist du sicher dass du flgendes Spiel l\u00f6schen m\u00f6chtest
addUpdateHeadingText = update
addUpdateBodyText = Bitte w\u00e4hle das Update-Verzeichniss aus.
addDLCHeadingText = ein DLC hinzufügen
addDLCBodyText = Bitte w\u00e4hle das DLC-Verzeichniss aus.
licensesLblHeadingText = cemu_UI
licensesLblBodyText = cemu_UI ist lizensiert unter der GNU GPL 3.\n\nJFoenix, Apache License 2.0\nminimal-json, MIT License\nsqlite-jdbc, Apache License 2.0\nApache Commons IO, Apache License 2.0\nApache Commons Logging, Apache License 2.0\nApache Commons Codec, Apache License 2.0\nApache Log4j 2, Apache License 2.0\n
showLicenses = Lizenzen \u00f6ffnen
aboutBtnHeadingText = cemu_UI
aboutBtnBodyText = Diese Programm wurde mit freier Software erstellt\nund ist lizensiert unter der GNU GPL 3.\n\nwww.mosad.xyz
cloudSyncWaringHeadingText = Spielst\u00e4nde über die Cloud syncronisieren (beta)
cloudSyncWaringBodyText = WARNING this is a completly WIP cloud save integration,\nit's NOT recomended to use this!!\n\nUse it on your own risk and backup everthing before!
cloudSyncErrorHeadingText = Fehler beim initialisieren der Cloud-Verbindung!
cloudSyncErrorBodyText = Fehler beim initialisieren der Cloud-Verbindung.\nBitte lade die app.log (welceh du im cemu_UI Verzeichniss findest)\nauf \"https://github.com/Seil0/cemu_UI/issues\" hoch.
addGameBtnHeadingText = eine neues Spiel zu cemu_Ui hinzuf\u00fcgen
addGameBtnBodyText =
addBtnReturnErrorHeadingText = Fehler beim hinzuf\u00fcgen des Spiels!
addBtnReturnErrorBodyText = Fehler beim hinzuf\u00fcgen des Spiels.\nEiner der benötigten Werte war leer, bitte versuche es erneut.
lastPlayed = zuletzt gespielt,
today = heute
yesterday = gestern
never = nie
# button strings
playBtnPlay = spieles
playBtnUpdating = updating...
playBtnCopyingFiles = kopiere Dateien...
smmdbDownloadBtnLoading = laden
smmdbDownloadBtnDownload = Download
okayBtnText = okay
cancelBtnText = abbruch
updateBtnCheckNow = Auf Update pr\u00FCfen
updateBtnChecking = Es wird nach Updates gesucht...
updateBtnNoUpdateAvailable = Kein Update verf\u00FCgbar
updateBtnUpdateAvailable = Update verf\u00FCgbar
#EditGameDialog
gameTitle = Spiel Titel
titleID = Titel ID
romPath = ROM Pfad
coverPath = Cover-Pfad
editGameDialogHeadingTextError = Fehler beim hinzuf\u00fcgen des Spiels!
editGameDialogBodyTextError = Fehler beim hinzuf\u00fcgen des Spiels.\nEiner der benötigten Werte war leer, bitte versuche es erneut.
editGameDialogSelectPathBtn = .rpx Datei ausw\u00E4hlen
editGameDialogSelectCoverBtn = cover Datei ausw\u00E4hlen

View File

@ -0,0 +1,87 @@
#HomeFlix-Local_en_US.properties US-English Local and default
# Buttons
aboutBtn = About
settingsBtn = Settings
addBtn = Add new Game
reloadRomsBtn = reload ROMs
smmdbBtn = smmdb
cemuTFBtn = choose directory
romTFBtn = choose directory
smmdbDownloadBtn = Download
playBtn = play
cloudSyncToggleBtn = cloud savegames (Google Drive)
autoUpdateToggleBtn = check for updates on startup
fullscreenToggleBtn = start game in fullscreen
# Labels
cemu_UISettingsLbl = cemu_UI Settings
cemuDirectoryLbl = cemu directory
romDirectoryLbl = ROM directory
mainColorLbl = main color
languageLbl = language
updateLbl = updates
branchLbl = branch
cemuSettingsLbl = cemu Settings
licensesLbl = Licenses
# Columns
titleColumn = title
idColumn = ID
starsColumn = stars
timeColumn = time
# Strings
editHeadingText = edit
editBodyText = You can edit the tile and ROM/cover path.
removeHeadingText = remove
removeBodyText = Are you sure you want to delete
addUpdateHeadingText = update
addUpdateBodyText = Please select the update root directory.
addDLCHeadingText = add a DLC to
addDLCBodyText = Please select the DLC root directory.
licensesLblHeadingText = cemu_UI
licensesLblBodyText = cemu_UI is licensed under the terms of GNU GPL 3.\n\nJFoenix, Apache License 2.0\nminimal-json, MIT License\nsqlite-jdbc, Apache License 2.0\nApache Commons IO, Apache License 2.0\nApache Commons Logging, Apache License 2.0\nApache Commons Codec, Apache License 2.0\nApache Log4j 2, Apache License 2.0\n
showLicenses = show licenses
aboutBtnHeadingText = cemu_UI
aboutBtnBodyText = This Application is made with free Software\nand licensed under the terms of GNU GPL 3.\n\nwww.mosad.xyz
cloudSyncWaringHeadingText = activate cloud savegame sync (beta)
cloudSyncWaringBodyText = WARNING this is a completely WIP cloud save integration,\nit's NOT recommended to use this!!\n\nUse it on your own risk and backup everything before!
cloudSyncErrorHeadingText = Error while initializing cloud sync!
cloudSyncErrorBodyText = There was some trouble while initializing cloud sync.\nPlease upload the app.log (which can be found in the cemu_UI directory)\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this.
addGameBtnHeadingText = add a new game to cemu_UI
addGameBtnBodyText =
addBtnReturnErrorHeadingText = Error while adding a new Game!
addBtnReturnErrorBodyText = There was some trouble adding your game.\nOne of the needed values was empty, please try again to add your game.
lastPlayed = Last played,
today = today
yesterday = yesterday
never = never
# button strings
playBtnPlay = play
playBtnUpdating = updating...
playBtnCopyingFiles = copying files...
smmdbDownloadBtnLoading = loading
smmdbDownloadBtnDownload = Download
okayBtnText = okay
cancelBtnText = cancel
updateBtnCheckNow = check now!
updateBtnChecking = checking for updates ...
updateBtnNoUpdateAvailable = no update available
updateBtnUpdateAvailable = update available
#EditGameDialog
gameTitle = game title
titleID = title ID
romPath = ROM path
coverPath = cover path
editGameDialogHeadingTextError = Error while adding a new Game!
editGameDialogBodyTextError = There was some trouble adding your game.\nOne of the needed values was empty, please try again to add your game.
editGameDialogSelectPathBtn = select .rpx file
editGameDialogSelectCoverBtn = select cover file

View File

@ -1,8 +1,5 @@
package com.cemu_UI.test;
import java.io.File;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@ -24,8 +21,7 @@ public class AppTest extends TestCase {
@SuppressWarnings("unused")
private void testClientsSecret() {
File client_secret = new File("/client_secret.json");
Assert.assertTrue(client_secret.exists());
}
/**