Skip to content

Commit

Permalink
Yet another fix.. Plus login window!! (unfinished login)
Browse files Browse the repository at this point in the history
  • Loading branch information
JFCaron authored and JFCaron committed Aug 8, 2016
1 parent 2823b66 commit 21f9d29
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 65 deletions.
9 changes: 1 addition & 8 deletions .project
Expand Up @@ -15,14 +15,7 @@
<arguments>
</arguments>
</buildCommand>
<resources>
<resource>
<directory>src/res</directory>
<includes>
<include>**/*.fxml</include>
</includes>
</resource>
</resources>

</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
Expand Down
30 changes: 21 additions & 9 deletions src/me/corriekay/pokegoutil/BlossomsPoGoManager.java
Expand Up @@ -14,20 +14,32 @@
public class BlossomsPoGoManager extends Application{

public static final String VERSION = "0.1.1-Beta";
public static final FXMLLoader LOADER = new FXMLLoader();
//public static final FXMLLoader LOADER = new FXMLLoader();

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) throws IOException {
@SuppressWarnings("static-access")
Parent root = (Parent) LOADER.load(getClass().getClassLoader().getResource("res/layout/ChooseGUIWindow.fxml"));
primaryStage.setScene(new Scene(root));
primaryStage.getIcons().add(new Image("/res/icon/PokeBall-icon.png"));
primaryStage.setTitle("Choose a GUI");
primaryStage.initStyle(StageStyle.UTILITY);
primaryStage.show();
public void start(Stage primaryStage){
//@SuppressWarnings("static-access")
openGUIChooser(primaryStage);
}

public void openGUIChooser(Stage primaryStage) {
if (primaryStage!=null) {
Parent root;
try {
root = (Parent) FXMLLoader.load(getClass().getClassLoader().getResource("resources/layout/ChooseGUIWindow.fxml"));
} catch (IOException e) {
System.err.println("Problem loading .fxml file: " + e.toString());
return;
}
primaryStage.setScene(new Scene(root));
primaryStage.getIcons().add(new Image("resources/icon/PokeBall-icon.png"));
primaryStage.setTitle("Choose a GUI");
primaryStage.initStyle(StageStyle.UTILITY);
primaryStage.show();
}
}
}
Expand Up @@ -12,14 +12,14 @@
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import me.corriekay.pokegoutil.BlossomsPoGoManager;
import me.corriekay.pokegoutil.controllers.AccountController;
import me.corriekay.pokegoutil.utils.Console;
import me.corriekay.pokegoutil.utils.Utilities;

public class ChooseGuiWindowController {
public class ChooseGuiWindowController extends Pane{

@FXML
private ResourceBundle resources;
Expand All @@ -35,22 +35,27 @@ public class ChooseGuiWindowController {

@FXML
void initialize() {

}

@FXML
void onNewGuiBtnClicked(ActionEvent event) throws IOException {
void onNewGuiBtnClicked(ActionEvent event){
oldGuiBtn.getScene().getWindow().hide();

@SuppressWarnings("static-access")
Parent root = (Parent) BlossomsPoGoManager.LOADER.load(ChooseGuiWindowController.class.getClassLoader().getResource("res/layout/MainWindow.fxml"));
//@SuppressWarnings("static-access")
Parent root;
try {
root = (Parent) FXMLLoader.load(ChooseGuiWindowController.class.getClassLoader().getResource("resources/layout/Login.fxml"));
} catch (IOException e) {
System.err.println("Error loading resource: resources/layout/Login.fxml" );
return;
}
Scene scene = new Scene(root);

Stage mainWindow = new Stage();

mainWindow.getIcons().add(new Image("/res/icon/PokeBall-icon.png"));
mainWindow.setTitle("Blossom's Pokémon Go Manager");
mainWindow.initStyle(StageStyle.UNIFIED);
mainWindow.getIcons().add(new Image("/resources/icon/PokeBall-icon.png"));
mainWindow.setTitle("Login");
mainWindow.initStyle(StageStyle.UTILITY);

mainWindow.setScene(scene);
mainWindow.show();
Expand All @@ -65,17 +70,13 @@ void onOldGuiBtnClicked(ActionEvent event) {
private Console console;

@Override
public void run() {
try {
Utilities.setNativeLookAndFeel();
console = new Console("Console", 0, 0, true);
console.setVisible(false);
AccountController.initialize(console);
AccountController.logOn();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
public void run() {
Utilities.setNativeLookAndFeel();
console = new Console("Console", 0, 0, true);
console.setVisible(false);
AccountController.initialize(console);
AccountController.logOn();

}
});
}
Expand Down
85 changes: 85 additions & 0 deletions src/me/corriekay/pokegoutil/GUI/controller/LoginController.java
@@ -0,0 +1,85 @@
package me.corriekay.pokegoutil.GUI.controller;

import java.io.IOException;
import java.text.NumberFormat;

import com.pokegoapi.api.player.PlayerProfile;
import com.pokegoapi.exceptions.InvalidCurrencyException;
import com.pokegoapi.exceptions.LoginFailedException;
import com.pokegoapi.exceptions.RemoteServerException;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import me.corriekay.pokegoutil.controllers.AccountController;

public class LoginController extends StackPane{

@FXML
private TextField user;

@FXML
private TextField password;

@FXML
private Button ptcLoginBtn;

@FXML
private Button googleAuthBtn;

@FXML
private void initialize(){
AccountController.initialize();
}

@FXML
void onGoogleAuthBtnClicked(ActionEvent event) {
//TODO actually do the login
//AccountController.logOnGoogleAuth();
openMainWindow();
}

@FXML
void onPTCLoginBtnClicked(ActionEvent event) {
//TODO actually do the login
//AccountController.logOnPTC(user.getText(), password.getText());
openMainWindow();
}

void openMainWindow() {
ptcLoginBtn.getScene().getWindow().hide();
Parent root;
try {
root = (Parent) FXMLLoader.load(ChooseGuiWindowController.class.getClassLoader().getResource("resources/layout/MainWindow.fxml"));
} catch (IOException e1) {
System.err.println("Error loading resource: resources/layout/MainWindow.fxml");
return;
}
Scene scene = new Scene(root);

Stage mainWindow = new Stage();

mainWindow.getIcons().add(new Image("resources/icon/PokeBall-icon.png"));
try {
NumberFormat f = NumberFormat.getInstance();
PlayerProfile pp = AccountController.getPlayerProfile();
mainWindow.setTitle(String.format("%s - Stardust: %s - Blossom's Pokémon Go Manager", pp.getPlayerData().getUsername(),
f.format(pp.getCurrency(PlayerProfile.Currency.STARDUST))));
} catch (InvalidCurrencyException | LoginFailedException | RemoteServerException | NullPointerException e) {
mainWindow.setTitle("Blossom's Pokémon Go Manager");
}

mainWindow.initStyle(StageStyle.UNIFIED);

mainWindow.setScene(scene);
mainWindow.show();
}
}
Expand Up @@ -6,8 +6,9 @@
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.VBox;

public class MainWindowController {
public class MainWindowController extends VBox{

@FXML
private ResourceBundle resources;
Expand Down Expand Up @@ -36,7 +37,8 @@ void onLogOffClicked(ActionEvent event) {

@FXML
void onQuitClicked(ActionEvent event) {

//TODO Kill in a more humane way, maybe...
System.exit(0);
}

@FXML
Expand Down

0 comments on commit 21f9d29

Please sign in to comment.