mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added support to change speed of time II
This commit is contained in:
parent
9f27e68285
commit
9911246ae5
@ -129,6 +129,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
case KeyEvent.VK_U: {
|
case KeyEvent.VK_U: {
|
||||||
int ms_ = msToAdd;
|
int ms_ = msToAdd;
|
||||||
|
System.out.println("going to add ms:" +msToAdd);
|
||||||
int s_ = msToAdd / 1000;
|
int s_ = msToAdd / 1000;
|
||||||
ms_ = ms_ - s_ * 1000;
|
ms_ = ms_ - s_ * 1000;
|
||||||
int m_ = msToAdd / 1000 / 60;
|
int m_ = msToAdd / 1000 / 60;
|
||||||
@ -181,9 +182,12 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
final double newSpeed = this.mainWindow.getSpeed();
|
final double newSpeed = this.mainWindow.getSpeed();
|
||||||
|
|
||||||
if(oldSpeed != newSpeed) {
|
if(oldSpeed != newSpeed) {
|
||||||
|
TTime t= TTime.ofMilliseconds(((int)(Math.pow(2,newSpeed) * 1000)));
|
||||||
Utils.showNotification("Speed was changed from " +
|
Utils.showNotification("Speed was changed from " +
|
||||||
((int)oldSpeed) +
|
((int)oldSpeed) +
|
||||||
" to: " + ((int)newSpeed) + " (" + (NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(Math.pow(2, newSpeed))) + ") (" + (newSpeed <= 21 ? TTime.ofMilliseconds(((int)(Math.pow(2,newSpeed) * 1000))) : "many") +" /1s)");
|
" to: " + ((int)newSpeed) + " (" + (NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(Math.pow(2, newSpeed))) + ") (" +
|
||||||
|
(newSpeed <= -10 ? "few" : (newSpeed <=21 ? t : "many"))
|
||||||
|
+" /1s)");
|
||||||
} else {
|
} else {
|
||||||
if(decrease){
|
if(decrease){
|
||||||
Utils.showNotification("Current speed cannot be decreased: " +
|
Utils.showNotification("Current speed cannot be decreased: " +
|
||||||
|
@ -829,6 +829,28 @@ public class MainWindow extends TWindow {
|
|||||||
timeCalcConfiguration.testEnabledProperty.setValue(false);
|
timeCalcConfiguration.testEnabledProperty.setValue(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(speed < -6) {
|
||||||
|
if(speed == -7) {
|
||||||
|
if(Math.random() > 0.5) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(speed == -8) {
|
||||||
|
if(Math.random() > 0.25) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(speed == -9) {
|
||||||
|
if(Math.random() > 0.125) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(speed == -10) {
|
||||||
|
if(Math.random() > 0.625) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(timeCalcConfiguration.testEnabledProperty.isDisabled()) {
|
if(timeCalcConfiguration.testEnabledProperty.isDisabled()) {
|
||||||
timeCalcConfiguration.testEnabledProperty.enable();
|
timeCalcConfiguration.testEnabledProperty.enable();
|
||||||
}
|
}
|
||||||
@ -853,7 +875,7 @@ public class MainWindow extends TWindow {
|
|||||||
if(time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
if(time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
||||||
}
|
}
|
||||||
int msShouldBeAdded = (int) (Math.pow(2, speed) * 100d);
|
int msShouldBeAdded = speed < -6 ? 1 : (int) (Math.pow(2, speed) * 100d);
|
||||||
this.timeCalcKeyAdapter.setMsToAdd(msShouldBeAdded);
|
this.timeCalcKeyAdapter.setMsToAdd(msShouldBeAdded);
|
||||||
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
||||||
|
|
||||||
@ -1279,12 +1301,13 @@ public class MainWindow extends TWindow {
|
|||||||
if(speed == Integer.MIN_VALUE) {
|
if(speed == Integer.MIN_VALUE) {
|
||||||
speed = 0;
|
speed = 0;
|
||||||
}
|
}
|
||||||
if(speed == -3){
|
if(speed == MIN_SPEED){
|
||||||
//nothing to do
|
//nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--this.speed;
|
--this.speed;
|
||||||
}
|
}
|
||||||
|
public static final int MIN_SPEED = -10;
|
||||||
|
|
||||||
public int getSpeed() {
|
public int getSpeed() {
|
||||||
return speed;
|
return speed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user