Skip to content
Snippets Groups Projects
Commit a34f5167 authored by Alexis Durgnat's avatar Alexis Durgnat :milky_way:
Browse files

Label change when journeying

parent c87b0aac
No related branches found
No related tags found
1 merge request!21*poof* final version
......@@ -71,6 +71,13 @@ public class Connection implements Serializable {
return new ArrayList<>(sections);
}
public Stop getFrom(){
return this.from;
}
public Stop getTo(){
return this.to;
}
/**
* Builder of Connection object
......
......@@ -75,6 +75,8 @@ public class MainWindowController implements Initializable {
private List<Connection> currentConnections;
private Connection currentJourney;
/**
* Shows a sad message when the API crashes.
*/
......@@ -252,6 +254,19 @@ public class MainWindowController implements Initializable {
}
}
/**
* Create a new journey and broadcast it
* @param app App context
* @param pnl Panel containing the journey information
*/
private void createJourney(AppContext app, Pane pnl) {
Integer pos = Integer.parseInt(pnl.getId());
app.getMessageManager().sendJoinedJourney(new JoinedJourney(app.getUser().get(), currentConnections.get(pos)));
currentJourney = currentConnections.get(pos);
currentJourneyLabel.setText("Vous voyagez de " + currentJourney.getFrom().getLocation().getName() + " vers "
+ currentJourney.getTo().getLocation().getName() + ".");
}
/**
* Parse the line and search for chat command.
* @param cmd The line to parse.
......@@ -357,8 +372,7 @@ public class MainWindowController implements Initializable {
connectionContainer.getChildren().add(pane);
pane.setOnMouseClicked(e -> {
Pane pnl = (Pane) e.getSource();
Integer pos = Integer.parseInt(pnl.getId());
app.getMessageManager().sendJoinedJourney(new JoinedJourney(app.getUser().get(), currentConnections.get(pos)));
createJourney(app, pnl);
});
});
}
......@@ -367,10 +381,8 @@ public class MainWindowController implements Initializable {
}
});
// Subscribe to chat message
app.getMessageManager().conditionalSubscribeChatMessage(
chatMessage -> {
app.getMessageManager().conditionalSubscribeChatMessage(chatMessage -> {
Platform.runLater(() -> {
User sender = chatMessage.getUser();
String message = sender.getName() + ": " + chatMessage.getMessage();
......@@ -380,9 +392,7 @@ public class MainWindowController implements Initializable {
drawMessage(message, AppConfig.CHAT_MESSAGE_ICON, AppConfig.COLOR_BLUE_10_OPACITY);
}
});
},
chatMessage -> !(app.getUser().get().getIgnoredUserList().contains(chatMessage.getUser()))
);
}, chatMessage -> !(app.getUser().get().getIgnoredUserList().contains(chatMessage.getUser())));
// Subscribe to joined journey
app.getMessageManager().conditionalSubscribeJoinedJourney(joinedJourney -> Platform.runLater(() -> {
......@@ -393,8 +403,7 @@ public class MainWindowController implements Initializable {
} else {
drawMessage(message, AppConfig.CHAT_MESSAGE_ICON, AppConfig.COLOR_BLUE_10_OPACITY);
}
}),
joinedJourney -> !(app.getUser().get().getIgnoredUserList().contains(joinedJourney.getUser())));
}), joinedJourney -> !(app.getUser().get().getIgnoredUserList().contains(joinedJourney.getUser())));
// Subscribe to left journey
app.getMessageManager().conditionalSubscribeLeftJourney(leftJourney -> Platform.runLater(() -> {
......@@ -405,8 +414,7 @@ public class MainWindowController implements Initializable {
} else {
drawMessage(message, AppConfig.CHAT_MESSAGE_ICON, AppConfig.COLOR_BLUE_10_OPACITY);
}
}),
leftJourney -> !(app.getUser().get().getIgnoredUserList().contains(leftJourney.getUser())));
}), leftJourney -> !(app.getUser().get().getIgnoredUserList().contains(leftJourney.getUser())));
// Login messages:
drawCommands();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment