Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX_GUI #257

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c5371f6
Cleanup unused imports, memory leaks
chrisfaltsetas May 3, 2019
6fb673c
Change JAdventure to be a JavaFX Application. Implement Main Menu scene
chrisfaltsetas May 3, 2019
8fddd7e
Setup custom quit event handler
chrisfaltsetas May 3, 2019
dd19f62
Initialize controller references for Main Menu
chrisfaltsetas May 3, 2019
24bd8f4
Create initial files for the profile menu
chrisfaltsetas May 4, 2019
5f5ba1f
Re-organize controllers. Add profile grid
chrisfaltsetas May 4, 2019
1adee8e
Complete profile menu design
chrisfaltsetas May 4, 2019
be49df8
Set on mouse click profile loading
chrisfaltsetas May 4, 2019
aec6a89
Set on mouse click profile deletion + alert
chrisfaltsetas May 4, 2019
46a084b
Add new game, class selector scene + removed unused FXML components f…
chrisfaltsetas May 4, 2019
b930419
Remove unused methods and classes
chrisfaltsetas May 4, 2019
b4f6dbb
Load character name - no implementation
chrisfaltsetas May 4, 2019
80ee17b
Complete character creation + first save (profile loading works prope…
chrisfaltsetas May 6, 2019
5075055
Add working welcome scene
chrisfaltsetas May 9, 2019
daacd92
Add welcome funcionality when loading profile
chrisfaltsetas May 10, 2019
4389e6a
Add empty Game scene with working save function
chrisfaltsetas May 10, 2019
cff392d
Create location descriptor and health bar
chrisfaltsetas May 10, 2019
f59ff4e
Add directional buttons
chrisfaltsetas May 11, 2019
79ecd40
Add 2 directional methods. Cleanup imports
chrisfaltsetas May 11, 2019
41abaaa
Allign new directional buttons correctly
chrisfaltsetas May 11, 2019
73619a7
Create minimap tiles
chrisfaltsetas May 14, 2019
6403e92
Color code minimap exits + reload after moving
chrisfaltsetas May 16, 2019
be229d1
Remove save option from alert on close request
chrisfaltsetas May 16, 2019
115a1bb
Setup simple terminal chat
chrisfaltsetas May 16, 2019
399dcc1
Enable wrap text
chrisfaltsetas May 16, 2019
43dfe19
Remove terminal-chat
chrisfaltsetas May 16, 2019
2a5239a
Block javafx version warnings and MenuBarSkin caused Exceptions from …
chrisfaltsetas May 16, 2019
2a8b660
Add visuals for existance of items/monsters/npcs around current location
chrisfaltsetas May 17, 2019
c48ea7d
Add backpack view
chrisfaltsetas May 17, 2019
52ea8e9
Resize and cleanup backpack
chrisfaltsetas May 17, 2019
dd1b9a0
Remove unused imports in GameController
chrisfaltsetas May 18, 2019
a1bc011
Delete saved profiles
chrisfaltsetas May 19, 2019
38a32fc
Add necessary profiles for maven test goal
chrisfaltsetas May 19, 2019
99236b2
Remove javafx version warning from Game.fxml
chrisfaltsetas May 19, 2019
515d863
Add new line in sewer rat intro
chrisfaltsetas May 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion json/original_data/npcs.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"rightHand": "hands"
}
],
"intro": "Hey, rat. . . you dead??\n*You let out a groan...*\nWhat are you doing?!? Don't you know it's crazy to sleep so close to the recruits' camp? A guard will come down those stairs soon enough and catch you! You'll end up being drafted! You better come back in.\nBy the way, what's your name?",
"intro": "Hey, rat. . . you dead??\n*You let out a groan...*\nWhat are you doing?!? Don't you know it's crazy to sleep so close to the recruits' camp?\nA guard will come down those stairs soon enough and catch you! You'll end up being drafted! You better come back in.\nBy the way, what's your name?",
"allies": [
"Sewer Rat"
],
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/com/jadventure/game/CharacterNameController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/jadventure/game/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public Client(String serverName, int port) {
}

public void getInput() {
Scanner input;
try {
input = new Scanner(System.in);
//Scanner input;
try (Scanner input = new Scanner(System.in)) {
//input = new Scanner(System.in);
String userInput = input.nextLine();
out.writeUTF(userInput);
} catch (IOException e) {
e.printStackTrace();
}
e.printStackTrace();
}
}
}

43 changes: 26 additions & 17 deletions src/main/java/com/jadventure/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ public class Game {
public Monster monster;
Player player = null;

public Game(Player player, String playerType) throws DeathException {
this.parser = new CommandParser(player);
this.player = player;
switch (playerType) {
case "new":
newGameStart(player);
break;
case "old":
QueueProvider.offer("Welcome back, " + player.getName() + "!");
QueueProvider.offer("");
player.getLocation().print();
gamePrompt(player);
break;
default:
QueueProvider.offer("Invalid player type");
break;
}
public Game(Player player, String playerType, JAdventure jAdventure) throws DeathException {

this.parser = new CommandParser(player);
this.player = player;
switch (playerType) {
case "new":
jAdventure.loadCharacterName(player, this);
break;
case "old":
jAdventure.loadWelcome(player, "old");
//player.getLocation().print();
//gamePrompt(player);
break;
default:
QueueProvider.offer("Invalid player type");
break;
}
}

/**
Expand All @@ -44,6 +44,15 @@ public Game(Player player, String playerType) throws DeathException {
* character and welcomes him / her. After that, it goes to the normal game prompt.
*/
public void newGameStart(Player player) throws DeathException {
LocationRepository locationRepo = GameBeans.getLocationRepository(player.getName());
this.player.setLocation(locationRepo.getInitialLocation());
player.save();
//QueueProvider.offer("Welcome to Silliya, " + player.getName() + ".");
//player.getLocation().print();
//gamePrompt(player);
}

public void newGameStart_old(Player player) throws DeathException {
QueueProvider.offer(player.getIntro());
String userInput = QueueProvider.take();
player.setName(userInput);
Expand Down
Loading