notifier: make flash cancelling more responsive
Currently the cancel check is only performed when the flash is on, and not off, making it perform one last flash when you provide input to the client when the flash is off.
This commit is contained in:
@@ -217,6 +217,28 @@ public class Notifier
|
||||
|
||||
FlashNotification flashNotification = runeLiteConfig.flashNotification();
|
||||
|
||||
if (Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart))
|
||||
{
|
||||
switch (flashNotification)
|
||||
{
|
||||
case FLASH_TWO_SECONDS:
|
||||
case SOLID_TWO_SECONDS:
|
||||
flashStart = null;
|
||||
return;
|
||||
case SOLID_UNTIL_CANCELLED:
|
||||
case FLASH_UNTIL_CANCELLED:
|
||||
// Any interaction with the client since the notification started will cancel it after the minimum duration
|
||||
if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused())
|
||||
{
|
||||
flashStart = null;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (client.getGameCycle() % 40 >= 20
|
||||
// For solid colour, fall through every time.
|
||||
&& (flashNotification == FlashNotification.FLASH_TWO_SECONDS
|
||||
@@ -229,29 +251,6 @@ public class Notifier
|
||||
graphics.setColor(FLASH_COLOR);
|
||||
graphics.fill(new Rectangle(client.getCanvas().getSize()));
|
||||
graphics.setColor(color);
|
||||
|
||||
if (!Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (flashNotification)
|
||||
{
|
||||
case FLASH_TWO_SECONDS:
|
||||
case SOLID_TWO_SECONDS:
|
||||
flashStart = null;
|
||||
break;
|
||||
case SOLID_UNTIL_CANCELLED:
|
||||
case FLASH_UNTIL_CANCELLED:
|
||||
// Any interaction with the client since the notification started will cancel it after the minimum duration
|
||||
if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused())
|
||||
{
|
||||
flashStart = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendNotification(
|
||||
|
||||
Reference in New Issue
Block a user