-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Chrisvenator/globally-show-bpm
Globally show bpm
- Loading branch information
Showing
15 changed files
with
180 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/MapGeneration/PatternGeneration/CommonMethods/Parser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package MapGeneration.PatternGeneration.CommonMethods; | ||
|
||
import java.util.function.Function; | ||
|
||
import static DataManager.Parameters.logger; | ||
|
||
public class Parser { | ||
public static <T extends Number> T parseValue(String input, String loggerLogAs, Function<String, T> parser, T defaultValue) { | ||
try { | ||
T parsedValue = parser.apply(input); | ||
logger.info("Current {}: {}", loggerLogAs, parsedValue); | ||
System.out.println("Current " + loggerLogAs + ": " + parsedValue); | ||
|
||
return parsedValue; | ||
} catch (NumberFormatException ex) { | ||
String errorMessage = loggerLogAs + ": " + input + " is not a number!"; | ||
logger.error(errorMessage); | ||
System.err.println(errorMessage); | ||
} | ||
|
||
return defaultValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/UserInterface/Elements/TextFields/GlobalTextFields/GlobalBPMField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package UserInterface.Elements.TextFields.GlobalTextFields; | ||
|
||
import DataManager.Parameters; | ||
import UserInterface.Elements.ElementTypes; | ||
import UserInterface.Elements.TextFields.MyGlobalTextField; | ||
import UserInterface.UserInterface; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.KeyEvent; | ||
|
||
import static DataManager.Parameters.BPM; | ||
import static DataManager.Parameters.logger; | ||
|
||
public class GlobalBPMField extends MyGlobalTextField { | ||
|
||
public GlobalBPMField(UserInterface ui) { | ||
super(ElementTypes.GLOBAL_BPM_FIELD, ui); | ||
|
||
JLabel label = new JLabel("BPM:"); | ||
label.setBounds(60, 50, 40, 20); | ||
if (Parameters.DARK_MODE) label.setForeground(Color.white); | ||
ui.add(label); | ||
|
||
this.addKeyListener(new BPMKeyListener("BPM")); | ||
logger.debug("GlobalBPMField initialized: {}", BPM); | ||
} | ||
|
||
public void setBPM(double bpm){ | ||
this.setText(bpm + ""); | ||
} | ||
|
||
private class BPMKeyListener extends NumericKeyListener { | ||
public BPMKeyListener(String name) { | ||
super(name, 18, "abc"); | ||
} | ||
|
||
@Override | ||
public void keyReleased(KeyEvent e) { | ||
super.setLabelText(GlobalBPMField.this.getText()); | ||
|
||
double value = getDoubleValue(); | ||
if (value >= 0) { | ||
BPM = value; | ||
setBPM(BPM); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.