From fbe9f71e706643a4568eb876e2214a5016c56866 Mon Sep 17 00:00:00 2001 From: dekvall Date: Sat, 19 Oct 2019 18:58:54 +0200 Subject: [PATCH] loottracker: add confirm dialog to reset all --- .../plugins/loottracker/LootTrackerPanel.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index 9dc783bab8..39a1b0134a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -40,6 +40,7 @@ import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.border.EmptyBorder; @@ -74,6 +75,10 @@ class LootTrackerPanel extends PluginPanel private static final String HTML_LABEL_TEMPLATE = "%s%s"; + private static final String SYNC_RESET_ALL_WARNING_TEXT = + "This will permanently delete the current loot from both the client and the RuneLite website."; + private static final String NO_SYNC_RESET_ALL_WARNING_TEXT = + "This will permanently delete the current loot from the client."; // When there is no loot, display this private final PluginErrorPanel errorPanel = new PluginErrorPanel(); @@ -312,6 +317,18 @@ class LootTrackerPanel extends PluginPanel final JMenuItem reset = new JMenuItem("Reset All"); reset.addActionListener(e -> { + final LootTrackerClient client = plugin.getLootTrackerClient(); + final boolean syncLoot = client != null && config.syncPanel(); + final int result = JOptionPane.showOptionDialog(overallPanel, + syncLoot ? SYNC_RESET_ALL_WARNING_TEXT : NO_SYNC_RESET_ALL_WARNING_TEXT, + "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, + null, new String[]{"Yes", "No"}, "No"); + + if (result != JOptionPane.YES_OPTION) + { + return; + } + // If not in detailed view, remove all, otherwise only remove for the currently detailed title records.removeIf(r -> r.matches(currentView)); boxes.removeIf(b -> b.matches(currentView)); @@ -320,8 +337,7 @@ class LootTrackerPanel extends PluginPanel logsContainer.repaint(); // Delete all loot, or loot matching the current view - LootTrackerClient client = plugin.getLootTrackerClient(); - if (client != null && config.syncPanel()) + if (syncLoot) { client.delete(currentView); }