Skip to content

Commit

Permalink
safly disable while other sourced regen
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jun 20, 2023
1 parent 1064e85 commit e29ebc2
Showing 1 changed file with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public void initializeUI(BowlerAbstractDevice pm) {
this.pm = pm;
autoRegen.setSelected(true);

autoRegen.setDisable(true);
disable();
autoRegen.setOnAction(event -> {
regenFromUiEvent();
});
regen.setDisable(true);
regen.setOnAction(event -> {
autoRegen.setSelected(true);
regenFromUiEvent();
Expand Down Expand Up @@ -138,10 +137,7 @@ private void regenFromUiEvent() {
}
timeSinceLastUpdate = System.currentTimeMillis();
if (autoRegen.isSelected()) {
autoRegen.setDisable(true);
if (radioOptions != null)
radioOptions.setDisable(true);
regen.setDisable(true);
disable();
}
baseManager.setAutoRegen(autoRegen.isSelected());
if (autoRegen.isSelected()) {
Expand All @@ -150,6 +146,13 @@ private void regenFromUiEvent() {
});
}

private void disable() {
autoRegen.setDisable(true);
if (radioOptions != null)
radioOptions.setDisable(true);
regen.setDisable(true);
}

private void finishLoading(MobileBase device) {

TreeItem<String> rootItem = null;
Expand Down Expand Up @@ -291,17 +294,24 @@ public void changed(ObservableValue<? extends Number> observable, Number oldValu
System.out.println("Progress listener " + newValue);
if (newValue.doubleValue() > 0.99) {
BowlerStudio.runLater(() -> {
autoRegen.setDisable(false);
if (radioOptions != null)
radioOptions.setDisable(false);
regen.setDisable(false);

enable();
});
}else {
BowlerStudio.runLater(() -> {
disable();
});
}
}


});
}

private void enable() {
autoRegen.setDisable(false);
if (radioOptions != null)
radioOptions.setDisable(false);
regen.setDisable(false);
}
private boolean hasWalking(MobileBase device) {
return device.getLegs().size() > 0 || device.getSteerable().size() > 0 || device.getDrivable().size() > 0;
}
Expand Down

0 comments on commit e29ebc2

Please sign in to comment.