Skip to content
Snippets Groups Projects
Commit d2517696 authored by Dallin Nickel (djn011)'s avatar Dallin Nickel (djn011)
Browse files

Add profile add and delete buttons functionality to mainscreen

parent cce70302
No related tags found
2 merge requests!65Prototype,!56Feature addmacros
......@@ -14,7 +14,7 @@ public class addProfile extends CommandStatus{
* Makes a new profile in our database
* @param name The name we will use for the profile
*/
public void AddProfile(String name){
public addProfile(String name){
if(profileDatabase.database().containsKey(name)){
successful = false;
errorMessage = "Profile with name "+ name +" already exists";
......
......@@ -4,6 +4,7 @@ import Controller.Action;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
......@@ -11,6 +12,9 @@ import javafx.stage.Stage;
import model.Hotkey;
import model.Modifier;
import model.OSInterface;
import model.profiles.commands.addProfile;
import model.profiles.commands.checkActive;
import model.profiles.commands.deleteProfile;
import org.jnativehook.NativeHookException;
import java.awt.event.KeyEvent;
......@@ -36,9 +40,9 @@ public class MainScreen extends Pane {
/*
Button to send user to screen to set a new keybind.
*/
/*
Button to send user to screen to set a new keybind.
*/
Button bKeybind = new Button("Set a Keybind");
bKeybind.setOnAction(e -> goToKeybind());
bKeybind.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 30; -fx-vertical-align: middle; " +
......@@ -47,9 +51,9 @@ public class MainScreen extends Pane {
bKeybind.setLayoutX(89);
bKeybind.setLayoutY(200);
/*
Button to send user to screen to set a new macro
*/
/*
Button to send user to screen to set a new macro
*/
Button bMacro = new Button("Bind a Key to Macro");
bMacro.setOnAction(e -> goToMacro());
bMacro.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 30; -fx-vertical-align: middle; " +
......@@ -58,9 +62,9 @@ public class MainScreen extends Pane {
bMacro.setLayoutX(438);
bMacro.setLayoutY(200);
/*
Button to send user to screen to set a new keybind.
*/
/*
Button to send user to screen to set a new keybind.
*/
Button bProgram = new Button("Bind a Key to Program");
bProgram.setOnAction(e -> System.out.println("Bind a Key to Program"));
bProgram.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 30; -fx-vertical-align: middle; " +
......@@ -70,11 +74,11 @@ public class MainScreen extends Pane {
bProgram.setLayoutY(450);
/*
Button to send user to screen to change mouse sensitivity
*/
/*
Button to send user to screen to change mouse sensitivity
*/
Button bMouseSens = new Button("Change Mouse Sensitivity");
bMouseSens.setOnAction(e -> System.out.println("Change Mouse Sensitivity"));
bMouseSens.setOnAction(e -> goToMouseSensitivity());
bMouseSens.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 30; -fx-vertical-align: middle; " +
"-fx-pref-width: 260px; -fx-pref-height: 150px; -fx-text-align: center;");
bMouseSens.setWrapText(true);
......@@ -91,9 +95,9 @@ public class MainScreen extends Pane {
/*
Button to toggle keybinds on/off
*/
/*
Button to toggle keybinds on/off
*/
Button bToggle = new Button("Toggle Keybinds On/Off");
bToggle.setOnAction(e -> System.out.println("Toggle On/Off"));
bToggle.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
......@@ -103,8 +107,8 @@ public class MainScreen extends Pane {
bToggle.setLayoutY(670);
/*
Drop down box to select profile
*/
Drop down box to select profile
*/
ComboBox<String> profileSelector = new ComboBox<String>();
profileSelector.getItems().add("Profile 1");
profileSelector.getItems().add("Profile 2");
......@@ -116,22 +120,30 @@ public class MainScreen extends Pane {
profileSelector.setLayoutY(45);
profileSelector.setOnAction(e -> System.out.println(profileSelector.getValue()));
/*
Button to add new profile
*/
/*
Button to add new profile
*/
Button bAddProfile = new Button("Add New Profile");
bAddProfile.setOnAction(e -> System.out.println("Add New Profile"));
bAddProfile.setOnAction(e -> goToAddProfile());
bAddProfile.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 200px; -fx-pref-height: 50px; -fx-text-align: center;");
bAddProfile.setWrapText(true);
bAddProfile.setLayoutX(315);
bAddProfile.setLayoutY(45);
/*
Button to delete the current profile
*/
/*
Button to delete the current profile
*/
Button bDelProfile = new Button("Delete Current Profile");
bDelProfile.setOnAction(e -> System.out.println("Delete Current Profile"));
bDelProfile.setOnAction(e -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Delete current profile?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
deleteProfile delP = new deleteProfile();
checkActive active = new checkActive();
delP.DeleteProfile(active.CheckActive().getName());
}
});
bDelProfile.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 200px; -fx-pref-height: 50px; -fx-text-align: center;");
bDelProfile.setWrapText(true);
......@@ -400,4 +412,66 @@ public class MainScreen extends Pane {
BV.getChildren().addAll(title, text, back);
}
/**
* Function called when user wishes to add a new profile. Reads in a profile name and creates a new profile. User can also
* use back button to return without making changes.
*/
private void goToAddProfile() {
AddProfileScreen profileScreen = new AddProfileScreen();
//Button to go back to main view
Button back = new Button("Back");
back.setLayoutX(510);
back.setLayoutY(700);
back.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
back.setOnAction(e -> primaryStage.setScene(mainScreenScene));
//Button to save name field and create profile
Button save = new Button("Save");
save.setLayoutX(640);
save.setLayoutY(700);
save.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
save.setOnAction(e -> {
new addProfile(profileScreen.getProfileName());
primaryStage.setScene(mainScreenScene);
});
primaryStage.setTitle("Add New Profile");
Scene profScene = new Scene(profileScreen, 800, 800);
primaryStage.setScene(profScene);
profileScreen.getChildren().addAll(back, save);
}
/**
* Function called when user wishes to change mouse sensitivity. Reads in a slider value, save button saves changes,
* back button does nothing and goes back to main screen.
*/
private void goToMouseSensitivity() {
MouseSensitivityScreen mouseSensScreen = new MouseSensitivityScreen();
//Button to go back to main view
Button back = new Button("Back");
back.setLayoutX(510);
back.setLayoutY(700);
back.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
back.setOnAction(e -> primaryStage.setScene(mainScreenScene));
//Button to save sensitivity and return to main screen
Button save = new Button("Save");
save.setLayoutX(640);
save.setLayoutY(700);
save.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
save.setOnAction(e -> {
System.out.println(mouseSensScreen.getSensitivity());
primaryStage.setScene(mainScreenScene);
});
primaryStage.setTitle("Add New Profile");
Scene sensScene = new Scene(mouseSensScreen, 800, 800);
primaryStage.setScene(sensScene);
mouseSensScreen.getChildren().addAll(back, save);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment