Skip to content

Commit

Permalink
Merge pull request #15 from Seil0/develop
Browse files Browse the repository at this point in the history
release 0.2.3
  • Loading branch information
Seil0 authored Jan 12, 2018
2 parents 9be124a + d3acf38 commit 1e2d408
Show file tree
Hide file tree
Showing 13 changed files with 774 additions and 490 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com</groupId>
<artifactId>cemu_UI</artifactId>
<version>0.2.2-SNAPSHOT</version>
<version>0.2.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>cemu_UI</name>
Expand Down
70 changes: 53 additions & 17 deletions src/main/java/com/cemu_UI/application/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@

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");
Expand All @@ -69,8 +69,7 @@ public class Main extends Application {
private File directory;
private File configFile;
private File gamesDBFile;
@SuppressWarnings("unused")
private File localDB;
private File reference_gamesFile;
private File pictureCache;
private static Logger LOGGER;

Expand All @@ -97,7 +96,7 @@ private void mainWindow(){
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 = loader.getController(); // Link of FXMLController and controller class
mainWindowController.setMain(this); // call setMain
cloudController = new CloudController(mainWindowController); // call cloudController constructor

Expand All @@ -106,13 +105,13 @@ private void mainWindow(){
directory = new File(dirLinux);
configFile = new File(dirLinux + "/config.xml");
gamesDBFile = new File(dirLinux + "/games.db");
localDB = new File(dirLinux+"/localRoms.db");
reference_gamesFile = new File(dirLinux + "/reference_games.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");
reference_gamesFile = new File(dirWin + "/reference_games.db");
pictureCache= new File(dirWin+"/picture_cache");
}

Expand All @@ -139,6 +138,8 @@ private void mainWindow(){
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)
Expand All @@ -149,12 +150,16 @@ private void mainWindow(){
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");
Expand All @@ -165,11 +170,12 @@ private void mainWindow(){

// loading settings and initialize UI, dbController.main() loads all databases
mainWindowController.init();
mainWindowController.dbController.main();
mainWindowController.dbController.init();

// if cloud sync is activated start sync
if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath());
}
mainWindowController.addUIData();

Expand Down Expand Up @@ -224,8 +230,6 @@ private void initActions() {
@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) {
Expand Down Expand Up @@ -308,4 +312,36 @@ public static void main(String[] args) {
public void stop() {
System.exit(0);
}

public Stage getPrimaryStage() {
return primaryStage;
}

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 void setDirectory(File directory) {
this.directory = directory;
}
}
Loading

0 comments on commit 1e2d408

Please sign in to comment.