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
0465ddb6
Commit
0465ddb6
authored
3 years ago
by
Dallin Nickel (djn011)
Browse files
Options
Downloads
Patches
Plain Diff
Error handling for if the user does not enter an item from the list
parent
20659cc0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!65
Prototype
,
!52
Feature addmacros
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ui/MainScreen.java
+77
-43
77 additions, 43 deletions
src/ui/MainScreen.java
with
77 additions
and
43 deletions
src/ui/MainScreen.java
+
77
−
43
View file @
0465ddb6
...
...
@@ -147,6 +147,9 @@ public class MainScreen extends Pane {
*/
private
void
goToKeybind
()
{
KeybindView
KBV
=
new
KeybindView
();
primaryStage
.
setTitle
(
"Set a Keybind"
);
Scene
testScene
=
new
Scene
(
KBV
,
800
,
800
);
primaryStage
.
setScene
(
testScene
);
//Button to go back to main view
Button
back
=
new
Button
(
"Back"
);
back
.
setLayoutX
(
510
);
...
...
@@ -162,25 +165,30 @@ 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
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
Action
newAction
=
new
Action
(
actionList
);
if
(
dict
.
containsKey
(
newHotkey
.
getKeyCode
())){
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"A binding already exists for that key\nRemove key before reassigning"
);
try
{
Hotkey
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
Action
newAction
=
new
Action
(
actionList
);
if
(
dict
.
containsKey
(
newHotkey
.
getKeyCode
())){
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"A binding already exists for that key\nRemove key before reassigning"
);
alert
.
show
();
primaryStage
.
setScene
(
mainScreenScene
);
return
;
}
dict
.
put
(
newHotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
newHotkey
);
}
catch
(
Exception
exception
)
{
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Please select a key and action from the list"
);
alert
.
show
();
primaryStage
.
setScene
(
mainScreenScene
);
goToKeybind
(
);
return
;
}
dict
.
put
(
newHotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
newHotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
});
primaryStage
.
setTitle
(
"Set a Keybind"
);
Scene
testScene
=
new
Scene
(
KBV
,
800
,
800
);
primaryStage
.
setScene
(
testScene
);
KBV
.
getChildren
().
addAll
(
back
,
save
);
...
...
@@ -206,17 +214,23 @@ public class MainScreen extends Pane {
add
.
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;"
);
add
.
setOnAction
(
e
->
{
Hotkey
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
if
(
dict
.
containsKey
(
newHotkey
.
getKeyCode
())){
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"A binding already exists for that key\nRemove key before reassigning"
);
try
{
Hotkey
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
if
(
dict
.
containsKey
(
newHotkey
.
getKeyCode
()))
{
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"A binding already exists for that key\nRemove key before reassigning"
);
alert
.
show
();
primaryStage
.
setScene
(
mainScreenScene
);
return
;
}
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
goToAddToMacro
(
newHotkey
,
actionList
);
}
catch
(
Exception
exception
)
{
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Please select a key and action from the list"
);
alert
.
show
();
primaryStage
.
setScene
(
mainScreenScene
);
return
;
goToMacro
();
}
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
goToAddToMacro
(
newHotkey
,
actionList
);
});
...
...
@@ -227,15 +241,21 @@ 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
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
Action
newAction
=
new
Action
(
actionList
);
dict
.
put
(
newHotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
newHotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
try
{
Hotkey
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
ArrayList
<
Integer
>
actionList
=
new
ArrayList
<>();
actionList
.
add
(
action
.
getKeyCode
());
Action
newAction
=
new
Action
(
actionList
);
dict
.
put
(
newHotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
newHotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
}
catch
(
Exception
exception
){
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Please select a key and action from the list"
);
alert
.
show
();
goToMacro
();
}
});
primaryStage
.
setTitle
(
"Set a Keybind"
);
Scene
testScene
=
new
Scene
(
KBV
,
800
,
800
);
...
...
@@ -266,10 +286,16 @@ public class MainScreen extends Pane {
add
.
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;"
);
add
.
setOnAction
(
e
->
{
//add the action to the list
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
added
.
add
(
action
.
getKeyCode
());
goToAddToMacro
(
hotkey
,
added
);
try
{
//add the action to the list
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
added
.
add
(
action
.
getKeyCode
());
goToAddToMacro
(
hotkey
,
added
);
}
catch
(
Exception
exception
){
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Please select an action from the list"
);
alert
.
show
();
goToAddToMacro
(
hotkey
,
added
);
}
});
Text
hotkeyName
=
new
Text
();
...
...
@@ -295,13 +321,21 @@ 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
action1
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
added
.
add
(
action1
.
getKeyCode
());
Action
newAction
=
new
Action
(
added
);
dict
.
put
(
hotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
hotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
try
{
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
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
hotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
}
catch
(
Exception
exception
){
Action
newAction
=
new
Action
(
added
);
dict
.
put
(
hotkey
.
getKeyCode
(),
newAction
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
hotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
}
});
primaryStage
.
setTitle
(
"Set a Macro"
);
...
...
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