From 69534cc3cf54bb4853e116994a2daf1e39cfd19a Mon Sep 17 00:00:00 2001 From: Cyborger1 <45152844+Cyborger1@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:20:27 -0400 Subject: [PATCH] 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. --- .../java/net/runelite/client/Notifier.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/Notifier.java b/runelite-client/src/main/java/net/runelite/client/Notifier.java index ce5db852c1..fc3083c997 100644 --- a/runelite-client/src/main/java/net/runelite/client/Notifier.java +++ b/runelite-client/src/main/java/net/runelite/client/Notifier.java @@ -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(