Added some improvements

This commit is contained in:
Robert Vokac 2024-03-24 14:52:27 +01:00
parent f28759ffd1
commit 54411412d8
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
8 changed files with 108 additions and 14 deletions

View File

@ -184,6 +184,7 @@ Smileys can be colored or white-black (can be set in configuration)
* CTRL + Q - Decrease speed of time
* ALT + Q - Reset speed of time
* COMMA - Switch between foreward and backward speed
* T - Enable or disable floating speed
* D - Reset custom time values to the real time
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time
@ -213,7 +214,6 @@ Smileys can be colored or white-black (can be set in configuration)
### Fix these known bugs
* Clock, square and circle are grey, if visibility mode is weakly colored.
* Decreasing real time sometimes does not work correctly.
## For Developers

View File

@ -263,6 +263,8 @@ public class TimeCalcConfiguration {
.getKey(), 1);
public final BooleanProperty speedNegativeProperty = new BooleanProperty(TimeCalcProperty.SPEED_NEGATIVE
.getKey(), false);
public final BooleanProperty speedFloatingProperty = new BooleanProperty(TimeCalcProperty.SPEED_FLOATING
.getKey(), false);
//
private final Map<TimeCalcProperty, Property> mapOfProperties
@ -340,6 +342,7 @@ public class TimeCalcConfiguration {
activityNeededFlagsProperty,
speedProperty,
speedNegativeProperty,
speedFloatingProperty,
clockHiddenProperty,
batteryMinuteHiddenProperty,
batteryHourHiddenProperty,

View File

@ -707,6 +707,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
timeCalcConfiguration.speedNegativeProperty.flip();
break;
}
case KeyEvent.VK_T: {
timeCalcConfiguration.speedFloatingProperty.flip();
break;
}
default:
if (!numberKeyWasPressed) {
Utils.showNotification(

View File

@ -125,7 +125,8 @@ public enum TimeCalcProperty {
TEST_CLOCK_CUSTOM_MILLISECOND("test.clock.custom.millisecond", "Test : Clock : Custom : Millisecond", Integer.class),
ACTIVITY_NEEDED_FLAGS("activity.needed-flags", "Activity : Needed flags", String.class),
SPEED("speed", "Speed", Integer.class),
SPEED_NEGATIVE("speed.negative", "Speed : Negative", Integer.class);
SPEED_NEGATIVE("speed.negative", "Speed : Negative", Integer.class),
SPEED_FLOATING("speed.floating", "Speed : Floating");
@Getter
private final String key;

View File

@ -230,6 +230,8 @@ public class ConfigWindow extends TWindow {
= new JTextField(TimeCalcProperty.SPEED.getKey());
public final JCheckBox speedNegativeProperty
= new JCheckBox(TimeCalcProperty.SPEED_NEGATIVE.getKey());
public final JCheckBox speedFloatingProperty
= new JCheckBox(TimeCalcProperty.SPEED_FLOATING.getKey());
//
public final JCheckBox clockHiddenProperty
@ -455,6 +457,14 @@ public class ConfigWindow extends TWindow {
moneyHiddenProperty.setSelected(!enable);
weatherHiddenProperty.setSelected(!enable);
dotHiddenProperty.setSelected(!enable);
if (enable) {
speedProperty.setText("0");
speedFloatingProperty.setSelected(true);
}
if (!enable) {
speedProperty.setText(String.valueOf(Integer.MIN_VALUE));
speedFloatingProperty.setSelected(false);
}
MainWindow.hideShowFormsCheckBox.setSelected(enable);
});
}
@ -549,6 +559,7 @@ public class ConfigWindow extends TWindow {
activityNeededFlagsProperty,
speedProperty,
speedNegativeProperty,
speedFloatingProperty,
visibilityDefaultProperty,
visibilitySupportedColoredProperty));
//

View File

@ -122,7 +122,6 @@ public class MainWindow extends TWindow {
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
private double msRemaining = 0d;
private final Time timeAlwaysReal;
private boolean floatingTime = false;
{
ChangeListener valueMustBeTime
@ -850,7 +849,12 @@ public class MainWindow extends TWindow {
new Timer(100, e -> {
if (speed == Integer.MIN_VALUE) {
//timeCalcConfiguration.testEnabledProperty.setValue(false);
return;
if (timeCalcConfiguration.speedFloatingProperty.isEnabled()) {
speed = 0;
} else {
return;
}
}
double r = Math.pow(2, speed + 6);
if (speed < -6 && Math.random() > r) {
@ -861,6 +865,7 @@ public class MainWindow extends TWindow {
if (timeCalcConfiguration.testEnabledProperty.isDisabled()) {
timeCalcConfiguration.testEnabledProperty.enable();
}
if (time.yearCustomProperty.getValue() == Integer.MAX_VALUE) {
time.yearCustomProperty.setValue(time.yearProperty.getValue());
}
@ -882,26 +887,92 @@ public class MainWindow extends TWindow {
if (time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
}
if (timeCalcConfiguration.speedFloatingProperty.isEnabled()) {
long nowTime = timeAlwaysReal.asCalendar().getTime().getTime();
long fakeTime = time.asCalendar().getTime().getTime();
long diff = fakeTime - nowTime;
boolean forewardMs = diff > 0;
boolean backwardMs = !forewardMs;
if (forewardMs && diff > 60000 && Math.random() > 0.95) {
speed = -2;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if (forewardMs && diff <= 60000 && Math.random() > 0.95) {
speed = 1;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if (backwardMs && diff < -60000 && Math.random() > 0.95) {
speed = 2;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if (backwardMs && diff >= -60000 && Math.random() > 0.95) {
speed = -1;
timeCalcConfiguration.speedProperty.setValue(speed);
}
{
if (forewardMs && diff > 600000 && Math.random() > 0.95) {
speed = -4;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if (backwardMs && diff < -600000 && Math.random() > 0.95) {
speed = 4;
timeCalcConfiguration.speedProperty.setValue(speed);
}
}
if (Math.random() > 0.95) {
speed = (int) (-8d + Math.random() * 8d);
timeCalcConfiguration.speedProperty.setValue(speed);
}
if(timeCalcConfiguration.speedNegativeProperty.isDisabled()){
if(Math.random() > 0.95 && Math.abs(diff) > 360000d * 6d) {
speed = (int) (backwardMs ? (5d + Math.random() * 5d) : (-5d - Math.random() * 3d)) ;
timeCalcConfiguration.speedProperty.setValue(speed);
}
}
if(Math.random() > 0.999 ) {
speed = 10;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if(Math.random() < 0.001 ) {
speed = -6;
timeCalcConfiguration.speedProperty.setValue(speed);
}
if(diff > 360000 * 3) {
timeCalcConfiguration.speedNegativeProperty.setValue(true);
} else {
timeCalcConfiguration.speedNegativeProperty.setValue(false);
}
// if(Math.random() > 0.98) {
// boolean add = Math.random() > 0.5;
// this.timeCalcKeyAdapter.setMsToAdd((int) ((add ? (1) : (-1)) * Math.random() * 360000d));
// this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, add, !add, false);
//
// }
}
double msShouldBeAdded = speed < -6 ? 1 : (Math.pow(2, speed) * 100d) + this.msRemaining;
int msShouldBeAddedInt = (int)Math.floor(msShouldBeAdded);
int msShouldBeAddedInt = (int) Math.floor(msShouldBeAdded);
this.msRemaining = msShouldBeAdded - msShouldBeAddedInt;
this.timeCalcKeyAdapter.setMsToAdd((timeCalcConfiguration.speedNegativeProperty.isEnabled() ? (-1) : 1) * msShouldBeAddedInt);
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
}).start();
this.timeCalcConfiguration.speedProperty.addListener(e -> {
int newSpeed = Integer.valueOf(timeCalcConfiguration.speedProperty.getValue());
if(newSpeed < MIN_SPEED) {
if (newSpeed < MIN_SPEED) {
newSpeed = MIN_SPEED;
}
this.speed = newSpeed;
});
int newSpeed = Integer.valueOf(timeCalcConfiguration.speedProperty.getValue());
if(newSpeed < MIN_SPEED) {
newSpeed = MIN_SPEED;
}
this.speed = newSpeed;
if (newSpeed < MIN_SPEED) {
newSpeed = MIN_SPEED;
}
this.speed = newSpeed;
while (true) {
if (Math.random() > 0.99) {
@ -1354,10 +1425,12 @@ public class MainWindow extends TWindow {
this.speed = Integer.MIN_VALUE;
timeCalcConfiguration.speedProperty.setValue(this.speed);
}
public void enableFloatingTime() {
this.floatingTime = true;
this.timeCalcConfiguration.speedFloatingProperty.enable();
}
public void disableFloatingTieme() {
this.floatingTime = false;
this.timeCalcConfiguration.speedFloatingProperty.disable();
}
}

View File

@ -184,6 +184,7 @@ Smileys can be colored or white-black (can be set in configuration)
* CTRL + Q - Decrease speed of time
* ALT + Q - Reset speed of time
* COMMA - Switch between foreward and backward speed
* T - Enable or disable floating speed
* D - Reset custom time values to the real time
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time
@ -213,7 +214,6 @@ Smileys can be colored or white-black (can be set in configuration)
### Fix these known bugs
* Clock, square and circle are grey, if visibility mode is weakly colored.
* Decreasing real time sometimes does not work correctly.
## For Developers

View File

@ -93,6 +93,7 @@ test.clock.custom.millisecond=2147483647
activity.needed-flags=
speed=0
speed.negative=false
speed.floating=false
#TODO:
logs.detailed=false