From 388aa0d08d348fab7448091c69e24c961e0b13f3 Mon Sep 17 00:00:00 2001 From: Matthew Thornton <44626690+ThorntonMatthewD@users.noreply.github.com> Date: Sun, 24 Oct 2021 20:03:21 -0400 Subject: [PATCH 1/4] Prediction breakdown panel hidden by default. Buttons placed at the bottom of the primary prediction panel which are used to toggle the visibility of the breakdown panel. Setting added to the config panel to allow for the breakdown panel to be visible by default. The aim is to cut down on the confusion brought on by the prediction breakdown by de-emphasizing it while still making it easily accessible. --- .../com/botdetector/BotDetectorConfig.java | 10 +++ .../com/botdetector/ui/BotDetectorPanel.java | 70 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/main/java/com/botdetector/BotDetectorConfig.java b/src/main/java/com/botdetector/BotDetectorConfig.java index ed027211..7b13c2fe 100644 --- a/src/main/java/com/botdetector/BotDetectorConfig.java +++ b/src/main/java/com/botdetector/BotDetectorConfig.java @@ -49,6 +49,7 @@ public interface BotDetectorConfig extends Config String SHOW_FEEDBACK_TEXTBOX = "showFeedbackTextbox"; String SHOW_DISCORD_VERIFICATION_ERRORS = "showDiscordVerificationErrors"; String ANONYMOUS_UUID_KEY = "anonymousUUID"; + String AUTO_SHOW_BREAKDOWN_PANEL_KEY = "autoShowBreakdownPanel"; int AUTO_SEND_MINIMUM_MINUTES = 5; int AUTO_SEND_MAXIMUM_MINUTES = 360; @@ -183,6 +184,15 @@ default PanelFontType panelFontType() return PanelFontType.NORMAL; } + @ConfigItem( + position = 5, + keyName = AUTO_SHOW_BREAKDOWN_PANEL_KEY, + name = "Auto Show Prediction Breakdown", + description = "Automatically shows the prediction breakdown panel when receiving a prediction.", + section = panelSection + ) + default boolean autoShowBreakdownPanel() {return false;} + @ConfigItem( position = 1, keyName = ADD_PREDICT_OPTION_KEY, diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index f19c83ee..8efdbf02 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -210,6 +210,8 @@ public enum WarningLabel private JLabel predictionPlayerNameLabel; private JLabel predictionTypeLabel; private JLabel predictionConfidenceLabel; + private JButton showPredictionBreakdownButton; + private JButton hidePredictionBreakdownButton; // Prediction Breakdown private JLabel predictionBreakdownLabel; @@ -705,6 +707,36 @@ private JPanel primaryPredictionPanel() primaryPredictionPanel.add(predictionConfidenceLabel, c); switchableFontComponents.add(predictionConfidenceLabel); + + showPredictionBreakdownButton = new JButton("Show Breakdown"); + showPredictionBreakdownButton.setToolTipText("View the complete breakdown of the prediction for the selected account." + + "
NOTE: We only utilize the primary prediction for our bot detection purposes."); + showPredictionBreakdownButton.setForeground(HEADER_COLOR); + showPredictionBreakdownButton.setFont(SMALL_FONT); + showPredictionBreakdownButton.addActionListener(l -> setPredictionBreakdownPanel(true)); + showPredictionBreakdownButton.setFocusable(false); + c.gridx = 0; + c.weightx = 0; + c.gridwidth = 2; + c.gridy++; + primaryPredictionPanel.add(showPredictionBreakdownButton, c); + setShowPredictionBreakdownButton(false); + + + hidePredictionBreakdownButton = new JButton("Hide Breakdown"); + hidePredictionBreakdownButton.setToolTipText("Close the prediction breakdown panel."); + hidePredictionBreakdownButton.setForeground(HEADER_COLOR); + hidePredictionBreakdownButton.setFont(SMALL_FONT); + hidePredictionBreakdownButton.addActionListener(l -> setPredictionBreakdownPanel(false)); + hidePredictionBreakdownButton.setFocusable(false); + c.gridx = 0; + c.weightx = 0; + c.gridwidth = 2; + c.gridy++; + primaryPredictionPanel.add(hidePredictionBreakdownButton, c); + setHidePredictionBreakdownButton(false); + + return primaryPredictionPanel; } @@ -1039,6 +1071,24 @@ public void setFeedbackTextboxVisible(boolean visible) feedbackTextScrollPane.setVisible(visible); } + /** + * Sets the visibility of the button that shows the prediction breakdown panel. + * @param visible The visibility to apply on the show prediction breakdown panel button. + */ + public void setShowPredictionBreakdownButton(boolean visible) + { + showPredictionBreakdownButton.setVisible(visible); + } + + /** + * Sets the visibility of the button that hide the prediction breakdown panel. + * @param visible The visibility to apply on the hide prediction breakdown panel button. + */ + public void setHidePredictionBreakdownButton(boolean visible) + { + hidePredictionBreakdownButton.setVisible(visible); + } + /** * Forcibly hides the feedback panel. */ @@ -1308,6 +1358,26 @@ else if (!isValidPlayerName(target)) })); } + /** + * Sets visibility of prediction breakdown panel and shows appropriate show/hide button in the primary panel. + * @param visible The desired visibility state of the breakdown panel. + */ + private void setPredictionBreakdownPanel(boolean visible) + { + predictionBreakdownPanel.setVisible(visible); + + if(visible) + { + setHidePredictionBreakdownButton(true); + setShowPredictionBreakdownButton(false); + } + else + { + setHidePredictionBreakdownButton(false); + setShowPredictionBreakdownButton(true); + } + } + /** * Processes the user input from the prediction feedback panel. * @param proposedLabel The intended label from the user for {@link #lastPrediction} to be sent to the API. From e7abba2812afeb8425ae3246dd9832adbec64269 Mon Sep 17 00:00:00 2001 From: Matthew Thornton <44626690+ThorntonMatthewD@users.noreply.github.com> Date: Sun, 24 Oct 2021 20:08:45 -0400 Subject: [PATCH 2/4] A change to setPrediction regarding the breakdown panel's visibility wasn't included in the previous commit for some reason. --- src/main/java/com/botdetector/ui/BotDetectorPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index 8efdbf02..447a2a83 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -1162,7 +1162,7 @@ public void setPrediction(Prediction pred, PlayerSighting sighting) else { predictionBreakdownLabel.setText(toPredictionBreakdownString(pred.getPredictionBreakdown())); - predictionBreakdownPanel.setVisible(true); + setPredictionBreakdownPanel(config.autoShowBreakdownPanel()); final String primaryLabel = pred.getPredictionLabel(); From c1739d2b06290839fb6d964033e25cdd4dac84e0 Mon Sep 17 00:00:00 2001 From: Matthew Thornton <44626690+ThorntonMatthewD@users.noreply.github.com> Date: Tue, 26 Oct 2021 08:20:58 -0400 Subject: [PATCH 3/4] No buttons on prediction error --- src/main/java/com/botdetector/ui/BotDetectorPanel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index 447a2a83..f2a7d08f 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -1241,6 +1241,8 @@ public void setPrediction(Prediction pred, PlayerSighting sighting) predictionConfidenceLabel.setText(EMPTY_LABEL); predictionBreakdownLabel.setText(EMPTY_LABEL); + setPredictionBreakdownPanel(false); + setShowPredictionBreakdownButton(false); predictionBreakdownPanel.setVisible(false); predictionFeedbackPanel.setVisible(false); predictionFlaggingPanel.setVisible(false); From 049486a18de051cda84859a06aa82e380d28e6ac Mon Sep 17 00:00:00 2001 From: Matthew Thornton <44626690+ThorntonMatthewD@users.noreply.github.com> Date: Tue, 2 Nov 2021 10:18:18 -0400 Subject: [PATCH 4/4] RL to 1.8 Remove Show/Hide Breakdown buttons if Auto Show Breakdown is enabled. --- build.gradle | 2 +- .../com/botdetector/BotDetectorPlugin.java | 3 + .../com/botdetector/ui/BotDetectorPanel.java | 55 ++++++++++++------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 58a31899..f0b1da0a 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ repositories { mavenCentral() } -def runeLiteVersion = '1.7.27' +def runeLiteVersion = '1.8.0' dependencies { compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion diff --git a/src/main/java/com/botdetector/BotDetectorPlugin.java b/src/main/java/com/botdetector/BotDetectorPlugin.java index c67abbbf..398ba984 100644 --- a/src/main/java/com/botdetector/BotDetectorPlugin.java +++ b/src/main/java/com/botdetector/BotDetectorPlugin.java @@ -628,6 +628,9 @@ private void onConfigChanged(ConfigChanged event) case BotDetectorConfig.ONLY_SEND_AT_LOGOUT_KEY: updateTimeToAutoSend(); break; + case BotDetectorConfig.AUTO_SHOW_BREAKDOWN_PANEL_KEY: + SwingUtilities.invokeLater(() -> panel.setPredictionBreakdownButtons()); + break; } } diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index f2a7d08f..df9c5bf0 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -1089,6 +1089,41 @@ public void setHidePredictionBreakdownButton(boolean visible) hidePredictionBreakdownButton.setVisible(visible); } + /** + * Sets visibility of prediction breakdown panel and shows appropriate show/hide button in the primary panel. + * @param visible The desired visibility state of the breakdown panel. + */ + private void setPredictionBreakdownPanel(boolean visible) + { + predictionBreakdownPanel.setVisible(visible); + + setPredictionBreakdownButtons(); + + } + + /** + * Sets visibility of the "Show Breakdown" and "Hide Breakdown" buttons in the Primary Prediction panel. + */ + public void setPredictionBreakdownButtons() + { + if(config.autoShowBreakdownPanel()) + { + //If the user opted to auto show prediction breakdown then hide buttons. + setHidePredictionBreakdownButton(false); + setShowPredictionBreakdownButton(false); + } + else if(predictionBreakdownPanel.isVisible()) + { + setHidePredictionBreakdownButton(true); + setShowPredictionBreakdownButton(false); + } + else + { + setHidePredictionBreakdownButton(false); + setShowPredictionBreakdownButton(true); + } + } + /** * Forcibly hides the feedback panel. */ @@ -1360,26 +1395,6 @@ else if (!isValidPlayerName(target)) })); } - /** - * Sets visibility of prediction breakdown panel and shows appropriate show/hide button in the primary panel. - * @param visible The desired visibility state of the breakdown panel. - */ - private void setPredictionBreakdownPanel(boolean visible) - { - predictionBreakdownPanel.setVisible(visible); - - if(visible) - { - setHidePredictionBreakdownButton(true); - setShowPredictionBreakdownButton(false); - } - else - { - setHidePredictionBreakdownButton(false); - setShowPredictionBreakdownButton(true); - } - } - /** * Processes the user input from the prediction feedback panel. * @param proposedLabel The intended label from the user for {@link #lastPrediction} to be sent to the API.