Skip to content

Commit

Permalink
refactored addexp cause its a dialog, josh plz
Browse files Browse the repository at this point in the history
  • Loading branch information
HIMISOCOOL committed Nov 4, 2014
1 parent 478af10 commit ecfe133
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 105 deletions.
192 changes: 89 additions & 103 deletions src/view/partials/CharacterProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import javafx.stage.WindowEvent;
import pathfinder.data.Classes.Class;
import view.RootController;

import view.partials.dialogs.AddExpController;

/**
* The Controller for the Character Controller
*
* @author Real Standard Studios - Matthew Meehan
*/
public class CharacterProfileController extends MainWindowController {
//region Profile Labels
// region Profile Labels
@FXML
Label lblName;
@FXML
Expand All @@ -53,9 +53,9 @@ public class CharacterProfileController extends MainWindowController {
Label lblDeity;
@FXML
Label lblLanguages;
//endregion
//region Class labels
// endregion

// region Class labels
@FXML
Label lblClass;
@FXML
Expand All @@ -70,17 +70,17 @@ public class CharacterProfileController extends MainWindowController {
TableColumn<Class, String> columnClass;
@FXML
TableColumn<Class, Integer> columnLevels;
//endregion
// endregion

@FXML
Button btnLevelUp;

@Override
public void initialize() {
columnClass.setCellValueFactory(cellData->cellData.getValue().getNameProperty());
columnLevels.setCellValueFactory(cellData->cellData.getValue().getLevelProp());
columnClass.setCellValueFactory(cellData -> cellData.getValue().getNameProperty());
columnLevels.setCellValueFactory(cellData -> cellData.getValue().getLevelProp());
}

/**
* sets the data for the Character Profile
*/
Expand All @@ -100,112 +100,98 @@ public void setData() {
lblRace.setText(character.getRace().getName());
lblWeight.setText(character.getFluff().get("Weight"));
lblClass.setText(character.getClasses()[0].getName());
lblLevel.setText(""+(character.getLevel() + 1));
lblExp.setText(""+character.getExperienceValue());
lblLevel.setText("" + (character.getLevel() + 1));
lblExp.setText("" + character.getExperienceValue());
tableClasses.setItems(FXCollections.observableArrayList(character.getClasses()));
}

@FXML
public void addExp()
{
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("AddExpDialog.fxml"));
AnchorPane page = (AnchorPane) loader.load();

// Create the dialog Stage.
Stage dialogStage = new Stage();
dialogStage.setTitle("Add Exp To Character");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initStyle(StageStyle.UTILITY);
dialogStage.initOwner(this.getInterface().getPrimaryStage());
dialogStage.resizableProperty().set(false);
Scene scene = new Scene(page);
dialogStage.setScene(scene);

// Set the person into the controller.
AddExpController controller = loader.getController();
controller.setDialogStage(dialogStage);
controller.setInterface(getInterface());
controller.loadPartials(((RootController) getRoot()).getCharacter(), this);
dialogStage.onCloseRequestProperty().set(new EventHandler<WindowEvent>() {

@Override
public void handle(WindowEvent event) {
controller.handleCancel(null);
}
});

// Show the dialog and wait until the user closes it
dialogStage.showAndWait();

} catch (IOException e) {
e.printStackTrace();

@FXML
public void addExp() {
if (((RootController) getRoot()).getCharacter() != null) {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("dialogs/AddExpDialog.fxml"));
AnchorPane page = (AnchorPane) loader.load();

// Create the dialog Stage.
Stage dialogStage = new Stage();
dialogStage.setTitle("Add Exp To Character");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initStyle(StageStyle.UTILITY);
dialogStage.initOwner(this.getInterface().getPrimaryStage());
dialogStage.resizableProperty().set(false);
Scene scene = new Scene(page);
dialogStage.setScene(scene);

// Set the person into the controller.
AddExpController controller = loader.getController();
controller.setDialogStage(dialogStage);
controller.setInterface(getInterface());
controller.loadPartials(((RootController) getRoot()).getCharacter(), this);
dialogStage.onCloseRequestProperty().set(new EventHandler<WindowEvent>() {

@Override
public void handle(WindowEvent event) {
controller.handleCancel(null);
}
});

// Show the dialog and wait until the user closes it
dialogStage.showAndWait();

} catch (IOException e) {
e.printStackTrace();
}
}
}



@FXML
public void handleLevelUp()
{
public void handleLevelUp() {
/*
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("dialogs/LevelUpDialog.fxml"));
AnchorPane page = (AnchorPane) loader.load();
// Create the dialog Stage.
Stage dialogStage = new Stage();
dialogStage.setTitle("LEVEL UP!");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initStyle(StageStyle.UTILITY);
dialogStage.initOwner(this.getInterface().getPrimaryStage());
dialogStage.resizableProperty().set(false);
Scene scene = new Scene(page);
dialogStage.setScene(scene);
// Set the person into the controller.
LevelUpController controller = loader.getController();
controller.setDialogStage(dialogStage);
controller.setInterface(getInterface());
//controller.loadPartials();
dialogStage.onCloseRequestProperty().set(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
controller.handleCancel(null);
}
});
// Show the dialog and wait until the user closes it
dialogStage.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
*/
* try { FXMLLoader loader = new FXMLLoader();
* loader.setLocation(this.getClass
* ().getResource("dialogs/LevelUpDialog.fxml")); AnchorPane page =
* (AnchorPane) loader.load();
*
* // Create the dialog Stage. Stage dialogStage = new Stage();
* dialogStage.setTitle("LEVEL UP!");
* dialogStage.initModality(Modality.WINDOW_MODAL);
* dialogStage.initStyle(StageStyle.UTILITY);
* dialogStage.initOwner(this.getInterface().getPrimaryStage());
* dialogStage.resizableProperty().set(false); Scene scene = new
* Scene(page); dialogStage.setScene(scene);
*
* // Set the person into the controller. LevelUpController controller =
* loader.getController(); controller.setDialogStage(dialogStage);
* controller.setInterface(getInterface()); //controller.loadPartials();
* dialogStage.onCloseRequestProperty().set(new
* EventHandler<WindowEvent>() {
*
* @Override public void handle(WindowEvent event) {
* controller.handleCancel(null); } });
*
* // Show the dialog and wait until the user closes it
* dialogStage.showAndWait();
*
* } catch (IOException e) { e.printStackTrace(); }
*/
}

public void updateExp()
{

public void updateExp() {
int oldLevel = Integer.parseInt(lblLevel.getText());
pathfinder.data.Character.Character character = ((RootController) getRoot()).getCharacter();

if(oldLevel < character.getLevel())
{

if (oldLevel < character.getLevel()) {
btnLevelUp.setDisable(false);
btnLevelUp.setVisible(true);
}

if(character.getLevel() < 20)
{
lblLevel.setText(""+(character.getLevel() + 1));
}
else
{

if (character.getLevel() < 20) {
lblLevel.setText("" + (character.getLevel() + 1));
} else {
lblLevel.setText("At Max Level");
}
lblExp.setText(""+character.getExperienceValue());
lblExp.setText("" + character.getExperienceValue());
character.getClasses()[0].setLevel(character.getLevel());
tableClasses.setItems(null);
this.initialize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package view.partials;
package view.partials.dialogs;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand All @@ -7,6 +7,8 @@

import org.controlsfx.dialog.Dialogs;

import view.partials.CharacterProfileController;

@SuppressWarnings("deprecation")
public class AddExpController extends DialogController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="108.0" prefWidth="314.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.partials.AddExpController">
<AnchorPane prefHeight="108.0" prefWidth="314.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.partials.dialogs.AddExpController">
<children>
<Button layoutX="201.0" layoutY="75.0" mnemonicParsing="false" onAction="#handleAddExp" text="Add" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="75.0" />
<Button layoutX="255.0" layoutY="75.0" mnemonicParsing="false" onAction="#handleCancel" text="Close" AnchorPane.bottomAnchor="14.0" />
Expand Down

0 comments on commit ecfe133

Please sign in to comment.