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

Add a button on the main screen to take the user to current keybinds,

Add the view for that button which shows current keybinds and allows the user to remove keybinds
parent 2ac4f589
No related branches found
No related tags found
2 merge requests!65Prototype,!52Feature addmacros
......@@ -27,4 +27,12 @@ public class Action {
OSInterface.getInstance().sendKey(i, true);
}
}
/**
* return all the keys in the action
* @return keys in the action
*/
public ArrayList<Integer> getKeys(){
return this.keyCodes;
}
}
\ No newline at end of file
package ui;
import javafx.scene.layout.Pane;
public class BlankView extends Pane {
public BlankView(){
this.setStyle("-fx-background-color: #99aab5;");
}
}
......@@ -81,6 +81,15 @@ public class MainScreen extends Pane {
bMouseSens.setLayoutX(438);
bMouseSens.setLayoutY(450);
Button bCurrentBindings = new Button("View Current Bindings");
bCurrentBindings.setOnAction(e -> goToCurrentBindings());
bCurrentBindings.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;");
bCurrentBindings.setWrapText(true);
bCurrentBindings.setLayoutX(300);
bCurrentBindings.setLayoutY(670);
/*
Button to toggle keybinds on/off
......@@ -130,7 +139,7 @@ public class MainScreen extends Pane {
bDelProfile.setLayoutY(45);
this.getChildren().addAll(bKeybind, bMacro, bProgram, bMouseSens, bToggle, profileSelector, bAddProfile, bDelProfile);
this.getChildren().addAll(bKeybind, bMacro, bProgram, bMouseSens, bToggle, bCurrentBindings, profileSelector, bAddProfile, bDelProfile);
}
/**
......@@ -235,6 +244,11 @@ public class MainScreen extends Pane {
}
/**
* intermediate stage for adding multiple keys to the chain
* @param hotkey hotkey to be added
* @param added list of added keys
*/
public void goToAddToMacro(Hotkey hotkey, ArrayList<Integer> added){
MacroView KBV = new MacroView();
//Button to go back to main view
......@@ -281,8 +295,8 @@ public class MainScreen extends Pane {
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 -> {
Hotkey action = new Hotkey(KBV.getKeyAction(), id, Modifier.NONE.val());
added.add(action.getKeyCode());
Hotkey action1 = new Hotkey(KBV.getKeyAction(), id, Modifier.NONE.val());
added.add(action1.getKeyCode());
Action newAction = new Action(added);
dict.put(hotkey.getKeyCode(), newAction);
id++;
......@@ -296,4 +310,59 @@ public class MainScreen extends Pane {
KBV.getChildren().addAll(back, add, save, hotkeyName, list);
}
/**
* Display the current keybindings in the current profile
*/
public void goToCurrentBindings(){
BlankView BV = new BlankView();
primaryStage.setTitle("Currently Bound Keys");
Scene testScene = new Scene(BV, 800, 800);
primaryStage.setScene(testScene);
int baseY = 110;
Button back = new Button("Back");
back.setLayoutX(640);
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));
Text title = new Text();
title.setLayoutY(100);
title.setLayoutX(50);
title.setText("Current Key Bindings: ");
title.setStyle("-fx-text-fill: #2c2f33; -fx-font-size: 30;");
Text text = new Text();
text.setLayoutY(130);
text.setLayoutX(100);
StringBuilder list = new StringBuilder("");
//Text to
for(Integer i: dict.keySet()){
list.append("Key: ");
list.append(KeyEvent.getKeyText(i));
list.append("\tAction(s): ");
for(Integer j: dict.get(i).getKeys()){
list.append(KeyEvent.getKeyText(j));
list.append(" ");
}
list.append("\n\n");
Button remove = new Button("Remove");;
remove.setLayoutX(700);
remove.setLayoutY(baseY);
baseY += 44;
remove.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 12; -fx-vertical-align: middle; " +
"-fx-pref-width: 75px; -fx-pref-height: 30px; -fx-text-align: center;");
remove.setOnAction(e -> {
dict.remove(i);
primaryStage.setScene(mainScreenScene);
});
BV.getChildren().add(remove);
}
text.setStyle("-fx-text-fill: #2c2f33; -fx-font-size: 15;");
text.setText(String.valueOf(list));
BV.getChildren().addAll(title, text, back);
}
}
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