Skip to content
Snippets Groups Projects
Commit 85e9d314 authored by keyno10's avatar keyno10
Browse files

Basic Attribute level added to UI

parent a3389cc4
No related branches found
No related tags found
No related merge requests found
package Character;
public class CharacterInterface {
private static final String name = "Jarren White";
private static final Attributes attributes = new Attributes(new int[]{7,1,7, 20,1,11, 1,1,5});
private static final Abilities abilities = new Abilities();
private static final Motes motes = new Motes(10, 5, 40, 3, 8);
private static final Health health = new Health(new int[]{0,0,0,-1,-1,-2}, new int[]{-2, -2, -2, -4}, 5);
public CharacterInterface() {
}
public static String getName() {
return name;
}
public static Attributes getAttributes() {
return attributes;
}
}
package UI;
import Character.CharacterInterface;
import Character.Attributes;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
public class Header extends VBox {
private Text name;
private HBox attributeGroup;
private Attributes attributes;
public Header() {
name = new Text(CharacterInterface.getName());
attributes = CharacterInterface.getAttributes();
attributeGroup = new HBox();
this.getChildren().add(name);
this.getChildren().add(attributeGroup);
populateMentalGroup();
populatePhysicalGroup();
populateSocialGroup();
}
private void populateMentalGroup() {
VBox box = new VBox();
box.getChildren().add(attributePair("Int", attributes.getInt()));
box.getChildren().add(attributePair("Wit", attributes.getWit()));
box.getChildren().add(attributePair("Res", attributes.getRes()));
attributeGroup.getChildren().add(box);
}
private void populatePhysicalGroup() {
VBox box = new VBox();
box.getChildren().add(attributePair("Str", attributes.getStr()));
box.getChildren().add(attributePair("Dex", attributes.getDex()));
box.getChildren().add(attributePair("Sta", attributes.getSta()));
attributeGroup.getChildren().add(box);
}
private void populateSocialGroup() {
VBox box = new VBox();
box.getChildren().add(attributePair("Pre", attributes.getPre()));
box.getChildren().add(attributePair("Man", attributes.getMan()));
box.getChildren().add(attributePair("Com", attributes.getCom()));
attributeGroup.getChildren().add(box);
}
/**
* Make & return HBox from given attribute & value
*/
private HBox attributePair(String attribute, SimpleIntegerProperty value) {
HBox pair = new HBox();
pair.getChildren().add(new Text(attribute));
Text number = new Text();
number.textProperty().bind(value.asString());
pair.getChildren().add(number);
return pair;
}
}
package UI;
import javafx.scene.layout.BorderPane;
public class Sheet extends BorderPane {
public Sheet() {
this.setTop(new Header());
}
}
package uk.ac.soton.comp1206;
import UI.Sheet;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
......@@ -13,8 +12,7 @@ public class App extends Application {
@Override
public void start(Stage stage) {
var label = new Label("Hello, JavaFX");
var scene = new Scene(new StackPane(label), 640, 480);
var scene = new Scene(new Sheet(), 640, 480);
stage.setScene(scene);
stage.show();
}
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment