Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sinister Zeta Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sinister Zeta
Sinister Zeta Project
Commits
d2517696
Commit
d2517696
authored
3 years ago
by
Dallin Nickel (djn011)
Browse files
Options
Downloads
Patches
Plain Diff
Add profile add and delete buttons functionality to mainscreen
parent
cce70302
Branches
revert-b11c6035
No related tags found
2 merge requests
!65
Prototype
,
!56
Feature addmacros
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/model/profiles/commands/addProfile.java
+1
-1
1 addition, 1 deletion
src/model/profiles/commands/addProfile.java
src/ui/MainScreen.java
+100
-26
100 additions, 26 deletions
src/ui/MainScreen.java
with
101 additions
and
27 deletions
src/model/profiles/commands/addProfile.java
+
1
−
1
View file @
d2517696
...
...
@@ -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
A
ddProfile
(
String
name
){
public
a
ddProfile
(
String
name
){
if
(
profileDatabase
.
database
().
containsKey
(
name
)){
successful
=
false
;
errorMessage
=
"Profile with name "
+
name
+
" already exists"
;
...
...
This diff is collapsed.
Click to expand it.
src/ui/MainScreen.java
+
100
−
26
View file @
d2517696
...
...
@@ -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
->
goTo
MouseSensitivity
(
));
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
->
goToAdd
Profile
(
));
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
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment