Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yet another fix.. Plus login window!! (unfinished login)
- Loading branch information
JFCaron
authored and
JFCaron
committed
Aug 8, 2016
1 parent
2823b66
commit 21f9d29
Showing
13 changed files
with
303 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/me/corriekay/pokegoutil/GUI/controller/LoginController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.