mirror of
https://github.com/badvision/jace.git
synced 2025-01-03 19:30:44 +00:00
Upstream fixes from Lawless Legends for keyboard focus and speed handling
This commit is contained in:
parent
142ee2df2a
commit
9cee0cece9
@ -81,12 +81,18 @@ public class EmulatorUILogic implements Reconfigurable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigurableField(
|
||||||
|
category = "General",
|
||||||
|
name = "Speed Setting"
|
||||||
|
)
|
||||||
|
public int speedSetting = 3;
|
||||||
|
|
||||||
@ConfigurableField(
|
@ConfigurableField(
|
||||||
category = "General",
|
category = "General",
|
||||||
name = "Show Drives"
|
name = "Show Drives"
|
||||||
)
|
)
|
||||||
public boolean showDrives = false;
|
public boolean showDrives = true;
|
||||||
|
|
||||||
public static void updateCPURegisters(MOS65C02 cpu) {
|
public static void updateCPURegisters(MOS65C02 cpu) {
|
||||||
// DebuggerPanel debuggerPanel = Emulator.getFrame().getDebuggerPanel();
|
// DebuggerPanel debuggerPanel = Emulator.getFrame().getDebuggerPanel();
|
||||||
@ -554,5 +560,6 @@ public class EmulatorUILogic implements Reconfigurable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reconfigure() {
|
public void reconfigure() {
|
||||||
|
JaceApplication.getApplication().controller.setSpeed(speedSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,11 @@ public class JaceUIController {
|
|||||||
assert stackPane != null : "fx:id=\"stackPane\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
assert stackPane != null : "fx:id=\"stackPane\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
||||||
assert notificationBox != null : "fx:id=\"notificationBox\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
assert notificationBox != null : "fx:id=\"notificationBox\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
||||||
assert appleScreen != null : "fx:id=\"appleScreen\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
assert appleScreen != null : "fx:id=\"appleScreen\" was not injected: check your FXML file 'JaceUI.fxml'.";
|
||||||
|
speedSlider.setValue(1.0);
|
||||||
controlOverlay.setVisible(false);
|
controlOverlay.setVisible(false);
|
||||||
menuButtonPane.setVisible(false);
|
menuButtonPane.setVisible(false);
|
||||||
|
controlOverlay.setFocusTraversable(false);
|
||||||
|
menuButtonPane.setFocusTraversable(false);
|
||||||
NumberBinding aspectCorrectedWidth = rootPane.heightProperty().multiply(3.0).divide(2.0);
|
NumberBinding aspectCorrectedWidth = rootPane.heightProperty().multiply(3.0).divide(2.0);
|
||||||
NumberBinding width = new When(
|
NumberBinding width = new When(
|
||||||
aspectRatioCorrectionEnabled.and(aspectCorrectedWidth.lessThan(rootPane.widthProperty()))
|
aspectRatioCorrectionEnabled.and(aspectCorrectedWidth.lessThan(rootPane.widthProperty()))
|
||||||
@ -125,6 +128,7 @@ public class JaceUIController {
|
|||||||
controlOverlay.setOnMouseClicked(this::hideControlOverlay);
|
controlOverlay.setOnMouseClicked(this::hideControlOverlay);
|
||||||
delayTimer.getKeyFrames().add(new KeyFrame(Duration.millis(3000), evt -> {
|
delayTimer.getKeyFrames().add(new KeyFrame(Duration.millis(3000), evt -> {
|
||||||
hideControlOverlay(null);
|
hideControlOverlay(null);
|
||||||
|
rootPane.requestFocus();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +143,11 @@ public class JaceUIController {
|
|||||||
ft.play();
|
ft.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rootPane.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timeline delayTimer = new Timeline();
|
Timeline delayTimer = new Timeline();
|
||||||
|
|
||||||
private void resetMenuButtonTimer() {
|
private void resetMenuButtonTimer() {
|
||||||
delayTimer.playFromStart();
|
delayTimer.playFromStart();
|
||||||
}
|
}
|
||||||
@ -155,6 +161,7 @@ public class JaceUIController {
|
|||||||
ft.setFromValue(0.0);
|
ft.setFromValue(0.0);
|
||||||
ft.setToValue(1.0);
|
ft.setToValue(1.0);
|
||||||
ft.play();
|
ft.play();
|
||||||
|
rootPane.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +182,7 @@ public class JaceUIController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double convertSpeedToRatio(Double setting) {
|
protected double convertSpeedToRatio(Double setting) {
|
||||||
if (setting < 1.0) {
|
if (setting < 1.0) {
|
||||||
return 0.5;
|
return 0.5;
|
||||||
} else if (setting == 1.0) {
|
} else if (setting == 1.0) {
|
||||||
@ -201,7 +208,6 @@ public class JaceUIController {
|
|||||||
rootPane.setOnKeyReleased(keyboardHandler);
|
rootPane.setOnKeyReleased(keyboardHandler);
|
||||||
rootPane.setFocusTraversable(true);
|
rootPane.setFocusTraversable(true);
|
||||||
}
|
}
|
||||||
speedSlider.setValue(1.0);
|
|
||||||
speedSlider.setMinorTickCount(0);
|
speedSlider.setMinorTickCount(0);
|
||||||
speedSlider.setMajorTickUnit(1);
|
speedSlider.setMajorTickUnit(1);
|
||||||
speedSlider.setLabelFormatter(new StringConverter<Double>() {
|
speedSlider.setLabelFormatter(new StringConverter<Double>() {
|
||||||
@ -226,6 +232,11 @@ public class JaceUIController {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
speedSlider.valueProperty().addListener((val, oldValue, newValue) -> setSpeed(newValue.doubleValue()));
|
speedSlider.valueProperty().addListener((val, oldValue, newValue) -> setSpeed(newValue.doubleValue()));
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
speedSlider.setValue(Emulator.logic.speedSetting);
|
||||||
|
// Kind of redundant but make sure speed is properly set as if the user did it
|
||||||
|
setSpeed(Emulator.logic.speedSetting);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectButtons(Node n) {
|
private void connectButtons(Node n) {
|
||||||
@ -240,10 +251,14 @@ public class JaceUIController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSpeed(double speed) {
|
protected void setSpeed(double speed) {
|
||||||
|
Emulator.logic.speedSetting = (int) speed;
|
||||||
double speedRatio = convertSpeedToRatio(speed);
|
double speedRatio = convertSpeedToRatio(speed);
|
||||||
|
if (speedSlider.getValue() != speed) {
|
||||||
|
Platform.runLater(()->speedSlider.setValue(speed));
|
||||||
|
}
|
||||||
if (speedRatio > 100.0) {
|
if (speedRatio > 100.0) {
|
||||||
Emulator.computer.getMotherboard().maxspeed = true;
|
Emulator.computer.getMotherboard().setMaxSpeed(true);
|
||||||
Motherboard.cpuPerClock = 3;
|
Motherboard.cpuPerClock = 3;
|
||||||
} else {
|
} else {
|
||||||
if (speedRatio > 25) {
|
if (speedRatio > 25) {
|
||||||
@ -251,8 +266,8 @@ public class JaceUIController {
|
|||||||
} else {
|
} else {
|
||||||
Motherboard.cpuPerClock = 1;
|
Motherboard.cpuPerClock = 1;
|
||||||
}
|
}
|
||||||
Emulator.computer.getMotherboard().maxspeed = false;
|
Emulator.computer.getMotherboard().setMaxSpeed(false);
|
||||||
Emulator.computer.getMotherboard().speedRatio = (int) (speedRatio * 100);
|
Emulator.computer.getMotherboard().setSpeedInPercentage((int) (speedRatio * 100));
|
||||||
}
|
}
|
||||||
Emulator.computer.getMotherboard().reconfigure();
|
Emulator.computer.getMotherboard().reconfigure();
|
||||||
}
|
}
|
||||||
@ -365,10 +380,12 @@ public class JaceUIController {
|
|||||||
|
|
||||||
private List<MediaConsumer> getMediaConsumers() {
|
private List<MediaConsumer> getMediaConsumers() {
|
||||||
List<MediaConsumer> consumers = new ArrayList<>();
|
List<MediaConsumer> consumers = new ArrayList<>();
|
||||||
for (Optional<Card> card : computer.memory.getAllCards()) {
|
if (Emulator.logic.showDrives) {
|
||||||
card.filter(c -> c instanceof MediaConsumerParent).ifPresent(parent -> {
|
for (Optional<Card> card : computer.memory.getAllCards()) {
|
||||||
consumers.addAll(Arrays.asList(((MediaConsumerParent) parent).getConsumers()));
|
card.filter(c -> c instanceof MediaConsumerParent).ifPresent(parent -> {
|
||||||
});
|
consumers.addAll(Arrays.asList(((MediaConsumerParent) parent).getConsumers()));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return consumers;
|
return consumers;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user