-
Notifications
You must be signed in to change notification settings - Fork 248
Expand file tree
/
Copy pathCharacterNameController.java
More file actions
78 lines (65 loc) · 1.78 KB
/
CharacterNameController.java
File metadata and controls
78 lines (65 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.jadventure.game;
import com.jadventure.game.entities.Player;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import javafx.stage.WindowEvent;
public class CharacterNameController {
// Reference to the main application.
private JAdventure jAdventure;
private Player player;
private Game game;
public CharacterNameController() {
}
@FXML
private MenuItem back;
@FXML
private MenuItem close;
@FXML
private MenuItem github;
@FXML
private Text intro;
@FXML
private TextField name;
@FXML
private Button create;
@FXML
public void createCharacter() throws DeathException {
player.setName(name.getText());
game.newGameStart(player);
jAdventure.loadWelcome(player, "new");
}
@FXML
public void goToMainMenu() {
jAdventure.loadMainMenu();
}
@FXML
public void goToGithub() {
// Goes to https://github.com/Progether/JAdventure
}
@FXML
public void quitGame() throws Exception {
jAdventure.getPrimaryStage().fireEvent(
new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST));
}
public void showIntro() {
intro.setText(player.getIntro());
}
/**
* Is called by the main application to give a reference back to itself.
*
* @param jAdventure
*/
public void setMainApp(JAdventure jAdventure) {
this.jAdventure = jAdventure;
}
public void setPlayer(Player player) {
this.player = player;
showIntro();
}
public void setGame(Game game) {
this.game = game;
}
}