Added default values, SystemCommandBuilder
Additionally removed sending of SystemCommands as messages and added sorting of recommendations by relevance.
This commit is contained in:
@ -30,6 +30,7 @@ import javafx.util.Duration;
|
||||
|
||||
import envoy.client.data.*;
|
||||
import envoy.client.data.audio.AudioRecorder;
|
||||
import envoy.client.data.commands.SystemCommandBuilder;
|
||||
import envoy.client.data.commands.SystemCommandsMap;
|
||||
import envoy.client.event.MessageCreationEvent;
|
||||
import envoy.client.net.Client;
|
||||
@ -129,8 +130,6 @@ public final class ChatScene implements Restorable {
|
||||
// Initialize message and user rendering
|
||||
messageList.setCellFactory(new ListCellFactory<>(MessageControl::new));
|
||||
chatList.setCellFactory(new ListCellFactory<>(ChatControl::new));
|
||||
messageTextAreaCommands.addNoArgCommand("DABR", text -> { doABarrelRoll(); return null; });
|
||||
messageTextAreaCommands.addNoArgCommand("DoABarrelRoll", text -> { doABarrelRoll(); return null; });
|
||||
|
||||
settingsButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("settings", DEFAULT_ICON_SIZE)));
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", DEFAULT_ICON_SIZE)));
|
||||
@ -208,6 +207,22 @@ public final class ChatScene implements Restorable {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all {@code SystemCommands} used in {@code ChatScene}.
|
||||
*
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
private void initializeSystemCommandsMap() {
|
||||
final var builder = new SystemCommandBuilder();
|
||||
// Do A Barrel roll initialization
|
||||
final var random = new Random();
|
||||
builder.setAction(text -> doABarrelRoll(Integer.parseInt(text.get(0)), Double.parseDouble(text.get(1))))
|
||||
.setDefaults(Integer.toString(random.nextInt(3) + 1), Double.toString(random.nextDouble() * 3 + 1))
|
||||
.setDescription("See for yourself :)")
|
||||
.setNumberOfArguments(2);
|
||||
messageTextAreaCommands.add("DABR", builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all necessary data via dependency injection-
|
||||
*
|
||||
@ -230,6 +245,7 @@ public final class ChatScene implements Restorable {
|
||||
if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info");
|
||||
|
||||
recorder = new AudioRecorder();
|
||||
initializeSystemCommandsMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -381,7 +397,8 @@ public final class ChatScene implements Restorable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates every element in our application by 360° in at most 2.75s.
|
||||
* Rotates every element in our application by (at most 4 *) 360° in at most
|
||||
* 2.75s.
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@ -498,9 +515,9 @@ public final class ChatScene implements Restorable {
|
||||
updateInfoLabel("You need to go online to send more messages", "infoLabel-error");
|
||||
return;
|
||||
}
|
||||
final var text = messageTextArea.getText().strip();
|
||||
messageTextAreaCommands.checkForCommands(text);
|
||||
try {
|
||||
final var text = messageTextArea.getText().strip();
|
||||
final var systemCommandPresent = messageTextAreaCommands.executeIfAnyPresent(text);
|
||||
if (systemCommandPresent) {} else try {
|
||||
// Creating the message and its metadata
|
||||
final var builder = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
|
||||
.setText(text);
|
||||
|
Reference in New Issue
Block a user