diff --git a/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java b/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java index aa2571a957..90c4c0c32d 100644 --- a/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java +++ b/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java @@ -188,7 +188,7 @@ public class SessionManager } catch (IOException ex) { - log.warn("Unable to logout of session", ex); + log.warn("Unable to sign out of session", ex); } accountSession = null; // No more account @@ -227,7 +227,7 @@ public class SessionManager @Subscribe public void onLoginResponse(LoginResponse loginResponse) { - log.debug("Now logged in as {}", loginResponse.getUsername()); + log.debug("Now signed in as {}", loginResponse.getUsername()); AccountSession session = getAccountSession(); session.setUsername(loginResponse.getUsername()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java index 501537654e..2cb1c66ded 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java @@ -75,14 +75,14 @@ public class AccountPlugin extends Plugin loginButton = NavigationButton.builder() .tab(false) .icon(LOGIN_IMAGE) - .tooltip("Log in to RuneLite") + .tooltip("Sign in to RuneLite") .onClick(this::loginClick) .build(); logoutButton = NavigationButton.builder() .tab(false) .icon(LOGOUT_IMAGE) - .tooltip("Log out of RuneLite") + .tooltip("Sign out of RuneLite") .onClick(this::logoutClick) .build(); @@ -113,7 +113,7 @@ public class AccountPlugin extends Plugin private void logoutClick() { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - "Are you sure you want to log out from RuneLite?", "Logout Confirmation", + "Are you sure you want to sign out of RuneLite?", "Sign Out Confirmation", JOptionPane.YES_NO_OPTION)) { executor.execute(sessionManager::logout); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index 246fd0aef8..cd0b7c8fa9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -189,7 +189,7 @@ public class InfoPanel extends PluginPanel syncPanel = buildLinkPanel(IMPORT_ICON, "Import signed-out", "settings", () -> { final int result = JOptionPane.showOptionDialog(syncPanel, - "This will overwrite your settings with settings from your local profile, which
is the profile used when not logged into RuneLite with a RuneLite account.", + "This will overwrite your settings with settings from your local profile, which
is the profile used when not signed into RuneLite with a RuneLite account.", "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{"Yes", "No"}, "No"); @@ -303,14 +303,14 @@ public class InfoPanel extends PluginPanel { emailLabel.setContentType("text/plain"); emailLabel.setText(name); - loggedLabel.setText("Logged in as"); + loggedLabel.setText("Signed in as"); actionsContainer.add(syncPanel, 0); } else { emailLabel.setContentType("text/html"); - emailLabel.setText("Login to sync settings to the cloud."); - loggedLabel.setText("Not logged in"); + emailLabel.setText("Sign in to sync settings to the cloud."); + loggedLabel.setText("Not signed in"); actionsContainer.remove(syncPanel); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java index abf9234a5e..983cfb45a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java @@ -92,7 +92,7 @@ public interface LootTrackerConfig extends Config @ConfigItem( keyName = "syncPanel", name = "Synchronize panel contents", - description = "Synchronize your local loot tracker with your server data (requires being logged in).
" + + description = "Synchronize your local loot tracker with your server data (requires being signed in).
" + " This means the panel is filled with portions of your remote data on startup
" + " and deleting data in the panel also deletes it on the server." ) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java index 1a8b23a8fa..8903a0b715 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java @@ -46,6 +46,9 @@ import net.runelite.client.util.SwingUtil; @Getter public class TimeablePanel extends JPanel { + private static final ImageIcon NOTIFY_ICON = new ImageIcon(ImageUtil.loadImageResource(TimeTrackingPlugin.class, "notify_icon.png")); + private static final ImageIcon NOTIFY_SELECTED_ICON = new ImageIcon(ImageUtil.loadImageResource(TimeTrackingPlugin.class, "notify_selected_icon.png")); + private final T timeable; private final JLabel icon = new JLabel(); private final JLabel farmingContractIcon = new JLabel(); @@ -84,13 +87,10 @@ public class TimeablePanel extends JPanel infoPanel.add(text); infoPanel.add(estimate); - ImageIcon notifyIcon = new ImageIcon(ImageUtil.loadImageResource(TimeTrackingPlugin.class, "notify_icon.png")); - ImageIcon notifySelectedIcon = new ImageIcon(ImageUtil.loadImageResource(TimeTrackingPlugin.class, "notify_selected_icon.png")); - notifyButton.setPreferredSize(new Dimension(30, 16)); notifyButton.setBorder(new EmptyBorder(0, 0, 0, 10)); - notifyButton.setIcon(notifyIcon); - notifyButton.setSelectedIcon(notifySelectedIcon); + notifyButton.setIcon(NOTIFY_ICON); + notifyButton.setSelectedIcon(NOTIFY_SELECTED_ICON); SwingUtil.removeButtonDecorations(notifyButton); SwingUtil.addModalTooltip(notifyButton, "Disable notifications", "Enable notifications"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java index bedaa1a95f..29ba121129 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java @@ -1,364 +1,402 @@ -/* - * Copyright (c) 2018, Psikoi - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.worldhopper; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.border.EmptyBorder; -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.client.ui.FontManager; -import net.runelite.client.util.ImageUtil; -import net.runelite.http.api.worlds.World; -import net.runelite.http.api.worlds.WorldRegion; -import net.runelite.http.api.worlds.WorldType; - -class WorldTableRow extends JPanel -{ - private static final ImageIcon FLAG_AUS; - private static final ImageIcon FLAG_UK; - private static final ImageIcon FLAG_US; - private static final ImageIcon FLAG_GER; - - private static final int WORLD_COLUMN_WIDTH = 60; - private static final int PLAYERS_COLUMN_WIDTH = 40; - private static final int PING_COLUMN_WIDTH = 35; - - private static final Color CURRENT_WORLD = new Color(66, 227, 17); - private static final Color DANGEROUS_WORLD = new Color(251, 62, 62); - private static final Color TOURNAMENT_WORLD = new Color(79, 145, 255); - private static final Color MEMBERS_WORLD = new Color(210, 193, 53); - private static final Color FREE_WORLD = new Color(200, 200, 200); - private static final Color SEASONAL_WORLD = new Color(133, 177, 178); - - static - { - FLAG_AUS = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_aus.png")); - FLAG_UK = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_uk.png")); - FLAG_US = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_us.png")); - FLAG_GER = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_ger.png")); - } - - private final JMenuItem favoriteMenuOption = new JMenuItem(); - - private JLabel worldField; - private JLabel playerCountField; - private JLabel activityField; - private JLabel pingField; - private final BiConsumer onFavorite; - - @Getter - private final World world; - - @Getter(AccessLevel.PACKAGE) - private int updatedPlayerCount; - - private int ping; - - private Color lastBackground; - - WorldTableRow(World world, boolean current, boolean favorite, Integer ping, Consumer onSelect, BiConsumer onFavorite) - { - this.world = world; - this.onFavorite = onFavorite; - this.updatedPlayerCount = world.getPlayers(); - - setLayout(new BorderLayout()); - setBorder(new EmptyBorder(2, 0, 2, 0)); - - addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent mouseEvent) - { - if (mouseEvent.getClickCount() == 2) - { - if (onSelect != null) - { - onSelect.accept(world); - } - } - } - - @Override - public void mousePressed(MouseEvent mouseEvent) - { - if (mouseEvent.getClickCount() == 2) - { - setBackground(getBackground().brighter()); - } - } - - @Override - public void mouseReleased(MouseEvent mouseEvent) - { - if (mouseEvent.getClickCount() == 2) - { - setBackground(getBackground().darker()); - } - } - - @Override - public void mouseEntered(MouseEvent mouseEvent) - { - WorldTableRow.this.lastBackground = getBackground(); - setBackground(getBackground().brighter()); - } - - @Override - public void mouseExited(MouseEvent mouseEvent) - { - setBackground(lastBackground); - } - }); - - setFavoriteMenu(favorite); - - final JPopupMenu popupMenu = new JPopupMenu(); - popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5)); - popupMenu.add(favoriteMenuOption); - - setComponentPopupMenu(popupMenu); - - JPanel leftSide = new JPanel(new BorderLayout()); - JPanel rightSide = new JPanel(new BorderLayout()); - leftSide.setOpaque(false); - rightSide.setOpaque(false); - - JPanel worldField = buildWorldField(); - worldField.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); - worldField.setOpaque(false); - - JPanel pingField = buildPingField(ping); - pingField.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); - pingField.setOpaque(false); - - JPanel playersField = buildPlayersField(); - playersField.setPreferredSize(new Dimension(PLAYERS_COLUMN_WIDTH, 0)); - playersField.setOpaque(false); - - JPanel activityField = buildActivityField(); - activityField.setBorder(new EmptyBorder(5, 5, 5, 5)); - activityField.setOpaque(false); - - recolour(current); - - leftSide.add(worldField, BorderLayout.WEST); - leftSide.add(playersField, BorderLayout.CENTER); - rightSide.add(activityField, BorderLayout.CENTER); - rightSide.add(pingField, BorderLayout.EAST); - - add(leftSide, BorderLayout.WEST); - add(rightSide, BorderLayout.CENTER); - } - - void setFavoriteMenu(boolean favorite) - { - String favoriteAction = favorite ? - "Remove " + world.getId() + " from favorites" : - "Add " + world.getId() + " to favorites"; - - favoriteMenuOption.setText(favoriteAction); - - for (ActionListener listener : favoriteMenuOption.getActionListeners()) - { - favoriteMenuOption.removeActionListener(listener); - } - - favoriteMenuOption.addActionListener(e -> - { - onFavorite.accept(world, !favorite); - }); - } - - void updatePlayerCount(int playerCount) - { - this.updatedPlayerCount = playerCount; - playerCountField.setText(playerCountString(playerCount)); - } - - private static String playerCountString(int playerCount) - { - return playerCount < 0 ? "OFF" : Integer.toString(playerCount); - } - - void setPing(int ping) - { - this.ping = ping; - pingField.setText(ping <= 0 ? "-" : Integer.toString(ping)); - } - - void hidePing() - { - pingField.setText("-"); - } - - void showPing() - { - setPing(ping); // to update pingField - } - - int getPing() - { - return ping; - } - - public void recolour(boolean current) - { - playerCountField.setForeground(current ? CURRENT_WORLD : Color.WHITE); - pingField.setForeground(current ? CURRENT_WORLD : Color.WHITE); - - if (current) - { - activityField.setForeground(CURRENT_WORLD); - worldField.setForeground(CURRENT_WORLD); - return; - } - else if (world.getTypes().contains(WorldType.PVP) - || world.getTypes().contains(WorldType.HIGH_RISK) - || world.getTypes().contains(WorldType.DEADMAN)) - { - activityField.setForeground(DANGEROUS_WORLD); - } - else if (world.getTypes().contains(WorldType.SEASONAL)) - { - activityField.setForeground(SEASONAL_WORLD); - } - else if (world.getTypes().contains(WorldType.NOSAVE_MODE)) - { - activityField.setForeground(TOURNAMENT_WORLD); - } - else - { - activityField.setForeground(Color.WHITE); - } - - worldField.setForeground(world.getTypes().contains(WorldType.MEMBERS) ? MEMBERS_WORLD : FREE_WORLD); - } - - /** - * Builds the players list field (containing the amount of players logged in that world). - */ - private JPanel buildPlayersField() - { - JPanel column = new JPanel(new BorderLayout()); - column.setBorder(new EmptyBorder(0, 5, 0, 5)); - - playerCountField = new JLabel(playerCountString(world.getPlayers())); - playerCountField.setFont(FontManager.getRunescapeSmallFont()); - - column.add(playerCountField, BorderLayout.WEST); - - return column; - } - - private JPanel buildPingField(Integer ping) - { - JPanel column = new JPanel(new BorderLayout()); - column.setBorder(new EmptyBorder(0, 5, 0, 5)); - - pingField = new JLabel("-"); - pingField.setFont(FontManager.getRunescapeSmallFont()); - - column.add(pingField, BorderLayout.EAST); - - if (ping != null) - { - setPing(ping); - } - - return column; - } - - /** - * Builds the activity list field (containing that world's activity/theme). - */ - private JPanel buildActivityField() - { - JPanel column = new JPanel(new BorderLayout()); - column.setBorder(new EmptyBorder(0, 5, 0, 5)); - - activityField = new JLabel(world.getActivity()); - activityField.setFont(FontManager.getRunescapeSmallFont()); - - column.add(activityField, BorderLayout.WEST); - - return column; - } - - /** - * Builds the world list field (containing the country's flag and the world index). - */ - private JPanel buildWorldField() - { - JPanel column = new JPanel(new BorderLayout(7, 0)); - column.setBorder(new EmptyBorder(0, 5, 0, 5)); - - worldField = new JLabel(world.getId() + ""); - - ImageIcon flagIcon = getFlag(world.getRegion()); - if (flagIcon != null) - { - JLabel flag = new JLabel(flagIcon); - column.add(flag, BorderLayout.WEST); - } - column.add(worldField, BorderLayout.CENTER); - - return column; - } - - private static ImageIcon getFlag(WorldRegion region) - { - if (region == null) - { - return null; - } - - switch (region) - { - case UNITED_STATES_OF_AMERICA: - return FLAG_US; - case UNITED_KINGDOM: - return FLAG_UK; - case AUSTRALIA: - return FLAG_AUS; - case GERMANY: - return FLAG_GER; - default: - return null; - } - } -} +/* + * Copyright (c) 2018, Psikoi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.worldhopper; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.client.ui.FontManager; +import net.runelite.client.util.ImageUtil; +import net.runelite.http.api.worlds.World; +import net.runelite.http.api.worlds.WorldRegion; +import net.runelite.http.api.worlds.WorldType; + +class WorldTableRow extends JPanel +{ + private static final ImageIcon FLAG_AUS; + private static final ImageIcon FLAG_UK; + private static final ImageIcon FLAG_US; + private static final ImageIcon FLAG_GER; + + private static final int WORLD_COLUMN_WIDTH = 60; + private static final int PLAYERS_COLUMN_WIDTH = 40; + private static final int PING_COLUMN_WIDTH = 35; + + private static final Color CURRENT_WORLD = new Color(66, 227, 17); + private static final Color DANGEROUS_WORLD = new Color(251, 62, 62); + private static final Color TOURNAMENT_WORLD = new Color(79, 145, 255); + private static final Color MEMBERS_WORLD = new Color(210, 193, 53); + private static final Color FREE_WORLD = new Color(200, 200, 200); + private static final Color SEASONAL_WORLD = new Color(133, 177, 178); + + static + { + FLAG_AUS = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_aus.png")); + FLAG_UK = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_uk.png")); + FLAG_US = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_us.png")); + FLAG_GER = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_ger.png")); + } + + private final JMenuItem favoriteMenuOption = new JMenuItem(); + + private JLabel worldField; + private JLabel playerCountField; + private JLabel activityField; + private JLabel pingField; + private final BiConsumer onFavorite; + + @Getter + private final World world; + + @Getter(AccessLevel.PACKAGE) + private int updatedPlayerCount; + + private int ping; + + private Color lastBackground; + + WorldTableRow(World world, boolean current, boolean favorite, Integer ping, Consumer onSelect, BiConsumer onFavorite) + { + this.world = world; + this.onFavorite = onFavorite; + this.updatedPlayerCount = world.getPlayers(); + + setLayout(new BorderLayout()); + setBorder(new EmptyBorder(2, 0, 2, 0)); + + addMouseListener(new MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent mouseEvent) + { + if (mouseEvent.getClickCount() == 2) + { + if (onSelect != null) + { + onSelect.accept(world); + } + } + } + + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (mouseEvent.getClickCount() == 2) + { + setBackground(getBackground().brighter()); + } + } + + @Override + public void mouseReleased(MouseEvent mouseEvent) + { + if (mouseEvent.getClickCount() == 2) + { + setBackground(getBackground().darker()); + } + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + WorldTableRow.this.lastBackground = getBackground(); + setBackground(getBackground().brighter()); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + setBackground(lastBackground); + } + }); + + setFavoriteMenu(favorite); + + final JPopupMenu popupMenu = new JPopupMenu(); + popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5)); + popupMenu.add(favoriteMenuOption); + + setComponentPopupMenu(popupMenu); + + JPanel leftSide = new JPanel(new BorderLayout()); + JPanel rightSide = new JPanel(new BorderLayout()); + leftSide.setOpaque(false); + rightSide.setOpaque(false); + + JPanel worldField = buildWorldField(); + worldField.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); + worldField.setOpaque(false); + + JPanel pingField = buildPingField(ping); + pingField.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); + pingField.setOpaque(false); + + JPanel playersField = buildPlayersField(); + playersField.setPreferredSize(new Dimension(PLAYERS_COLUMN_WIDTH, 0)); + playersField.setOpaque(false); + + JPanel activityField = buildActivityField(); + activityField.setBorder(new EmptyBorder(5, 5, 5, 5)); + activityField.setOpaque(false); + + recolour(current); + + leftSide.add(worldField, BorderLayout.WEST); + leftSide.add(playersField, BorderLayout.CENTER); + rightSide.add(activityField, BorderLayout.CENTER); + rightSide.add(pingField, BorderLayout.EAST); + + add(leftSide, BorderLayout.WEST); + add(rightSide, BorderLayout.CENTER); + } + + void setFavoriteMenu(boolean favorite) + { + String favoriteAction = favorite ? + "Remove " + world.getId() + " from favorites" : + "Add " + world.getId() + " to favorites"; + + favoriteMenuOption.setText(favoriteAction); + + for (ActionListener listener : favoriteMenuOption.getActionListeners()) + { + favoriteMenuOption.removeActionListener(listener); + } + + favoriteMenuOption.addActionListener(e -> + { + onFavorite.accept(world, !favorite); + }); + } + + void updatePlayerCount(int playerCount) + { + this.updatedPlayerCount = playerCount; + playerCountField.setText(playerCountString(playerCount)); + } + + private static String playerCountString(int playerCount) + { + return playerCount < 0 ? "OFF" : Integer.toString(playerCount); + } + + void setPing(int ping) + { + this.ping = ping; + pingField.setText(ping <= 0 ? "-" : Integer.toString(ping)); + } + + void hidePing() + { + pingField.setText("-"); + } + + void showPing() + { + setPing(ping); // to update pingField + } + + int getPing() + { + return ping; + } + + public void recolour(boolean current) + { + playerCountField.setForeground(current ? CURRENT_WORLD : Color.WHITE); + pingField.setForeground(current ? CURRENT_WORLD : Color.WHITE); + + if (current) + { + activityField.setForeground(CURRENT_WORLD); + worldField.setForeground(CURRENT_WORLD); + return; + } + else if (world.getTypes().contains(WorldType.PVP) + || world.getTypes().contains(WorldType.HIGH_RISK) + || world.getTypes().contains(WorldType.DEADMAN)) + { + activityField.setForeground(DANGEROUS_WORLD); + } + else if (world.getTypes().contains(WorldType.SEASONAL)) + { + activityField.setForeground(SEASONAL_WORLD); + } + else if (world.getTypes().contains(WorldType.NOSAVE_MODE)) + { + activityField.setForeground(TOURNAMENT_WORLD); + } + else + { + activityField.setForeground(Color.WHITE); + } + + worldField.setForeground(world.getTypes().contains(WorldType.MEMBERS) ? MEMBERS_WORLD : FREE_WORLD); + } + + /** + * Builds the players list field (containing the amount of players logged in that world). + */ + private JPanel buildPlayersField() + { + JPanel column = new JPanel(new BorderLayout()); + column.setBorder(new EmptyBorder(0, 5, 0, 5)); + + playerCountField = new JLabel(playerCountString(world.getPlayers())); + playerCountField.setFont(FontManager.getRunescapeSmallFont()); + + column.add(playerCountField, BorderLayout.WEST); + + return column; + } + + private JPanel buildPingField(Integer ping) + { + JPanel column = new JPanel(new BorderLayout()); + column.setBorder(new EmptyBorder(0, 5, 0, 5)); + + pingField = new JLabel("-"); + pingField.setFont(FontManager.getRunescapeSmallFont()); + + column.add(pingField, BorderLayout.EAST); + + if (ping != null) + { + setPing(ping); + } + + return column; + } + + /** + * Builds the activity list field (containing that world's activity/theme). + */ + private JPanel buildActivityField() + { + JPanel column = new JPanel(new BorderLayout()); + column.setBorder(new EmptyBorder(0, 5, 0, 5)); + + String activity = world.getActivity(); + activityField = new JLabel(activity); + activityField.setFont(FontManager.getRunescapeSmallFont()); + if (activity != null && activity.length() > 16) + { + activityField.setToolTipText(activity); + // Pass up events - https://stackoverflow.com/a/14932443 + activityField.addMouseListener(new MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent e) + { + dispatchEvent(e); + } + + @Override + public void mousePressed(MouseEvent e) + { + dispatchEvent(e); + } + + @Override + public void mouseReleased(MouseEvent e) + { + dispatchEvent(e); + } + + @Override + public void mouseEntered(MouseEvent e) + { + dispatchEvent(e); + } + + @Override + public void mouseExited(MouseEvent e) + { + dispatchEvent(e); + } + }); + } + + column.add(activityField, BorderLayout.WEST); + + return column; + } + + /** + * Builds the world list field (containing the country's flag and the world index). + */ + private JPanel buildWorldField() + { + JPanel column = new JPanel(new BorderLayout(7, 0)); + column.setBorder(new EmptyBorder(0, 5, 0, 5)); + + worldField = new JLabel(world.getId() + ""); + + ImageIcon flagIcon = getFlag(world.getRegion()); + if (flagIcon != null) + { + JLabel flag = new JLabel(flagIcon); + column.add(flag, BorderLayout.WEST); + } + column.add(worldField, BorderLayout.CENTER); + + return column; + } + + private static ImageIcon getFlag(WorldRegion region) + { + if (region == null) + { + return null; + } + + switch (region) + { + case UNITED_STATES_OF_AMERICA: + return FLAG_US; + case UNITED_KINGDOM: + return FLAG_UK; + case AUSTRALIA: + return FLAG_AUS; + case GERMANY: + return FLAG_GER; + default: + return null; + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java index 7bf9672c87..3886855a53 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/Overlay.java @@ -129,10 +129,7 @@ public abstract class Overlay implements LayoutableRenderableEntity return null; } - public void reset() + public void revalidate() { - setPreferredPosition(null); - setPreferredSize(null); - setPreferredLocation(null); } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayManager.java index 21cb834ca1..bea3f9d280 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayManager.java @@ -289,8 +289,11 @@ public class OverlayManager */ public synchronized void resetOverlay(final Overlay overlay) { - overlay.reset(); + overlay.setPreferredPosition(null); + overlay.setPreferredSize(null); + overlay.setPreferredLocation(null); saveOverlay(overlay); + overlay.revalidate(); } synchronized void rebuildOverlayLayers() diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java index 3ed548a91f..51f719e3fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java @@ -289,25 +289,18 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener final Dimension dimension = bounds.getSize(); final Point preferredLocation = overlay.getPreferredLocation(); Point location; + Rectangle snapCorner = null; // If the final position is not modified, layout it if (overlayPosition != OverlayPosition.DETACHED && (preferredLocation == null || overlay.getPreferredPosition() != null)) { - final Rectangle snapCorner = snapCorners.forPosition(overlayPosition); + snapCorner = snapCorners.forPosition(overlayPosition); final Point translation = OverlayUtil.transformPosition(overlayPosition, dimension); // offset from corner // Target x/y to draw the overlay - int destX = (int) snapCorner.getX() + translation.x; - int destY = (int) snapCorner.getY() + translation.y; + int destX = snapCorner.x + translation.x; + int destY = snapCorner.y + translation.y; // Clamp the target position to ensure it is on screen or within parent bounds location = clampOverlayLocation(destX, destY, dimension.width, dimension.height, overlay); - // Diff final position to target position in order to add it to the snap corner padding. The - // overlay effectively takes up the difference of (clamped location - target location) in - // addition to its normal dimensions. - int dX = location.x - destX; - int dY = location.y - destY; - final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING); // overlay size + fixed padding - // translate corner for padding and any difference due to the position clamping - snapCorner.translate(padding.x + dX, padding.y + dY); } else { @@ -324,6 +317,12 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener safeRender(client, overlay, layer, graphics, location); + // Adjust snap corner based on where the overlay was drawn + if (snapCorner != null && bounds.width + bounds.height > 0) + { + OverlayUtil.shiftSnapCorner(overlayPosition, snapCorner, bounds, PADDING); + } + // Restore graphics2d properties prior to drawing bounds graphics.setTransform(transform); graphics.setStroke(stroke); @@ -703,7 +702,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener { OverlayPosition position = snapCorners.fromBounds(snapCorner); - if (position == currentManagedOverlay.getPosition()) + if (position == getCorrectedOverlayPosition(currentManagedOverlay)) { // overlay moves back to default position position = null; @@ -711,6 +710,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener currentManagedOverlay.setPreferredPosition(position); currentManagedOverlay.setPreferredLocation(null); // from dragging + currentManagedOverlay.revalidate(); break; } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java index 1caa3a7c01..26497ab43d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java @@ -30,6 +30,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; +import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Stroke; @@ -201,33 +202,32 @@ public class OverlayUtil graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } - public static java.awt.Point padPosition(OverlayPosition position, Dimension dimension, final int padding) + static void shiftSnapCorner(OverlayPosition overlayPosition, Rectangle snapCorner, Rectangle bounds, int padding) { - final java.awt.Point result = new java.awt.Point(); - - switch (position) + // translate corner for padding and also based on where the overlay bounds are now + int sX = snapCorner.x, sY = snapCorner.y; + switch (overlayPosition) { - case DYNAMIC: - case TOOLTIP: - break; case BOTTOM_LEFT: - result.x += dimension.width + (dimension.width == 0 ? 0 : padding); + sX = bounds.x + bounds.width + padding; break; case BOTTOM_RIGHT: - result.x -= dimension.width + (dimension.width == 0 ? 0 : padding); + sX = bounds.x - padding; break; case TOP_LEFT: case TOP_CENTER: case CANVAS_TOP_RIGHT: case TOP_RIGHT: - result.y += dimension.height + (dimension.height == 0 ? 0 : padding); + sY = bounds.y + bounds.height + padding; break; case ABOVE_CHATBOX_RIGHT: - result.y -= dimension.height + (dimension.height == 0 ? 0 : padding); + sY = bounds.y - padding; break; + default: + throw new IllegalArgumentException(); } - - return result; + snapCorner.x = sX; + snapCorner.y = sY; } public static java.awt.Point transformPosition(OverlayPosition position, Dimension dimension) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java index 67d20cf8bd..43a1faf32e 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java @@ -121,9 +121,9 @@ public class WidgetOverlay extends Overlay assert widget != null; final Rectangle bounds = getBounds(); - // OverlayRenderer sets the overlay bounds to the preferred location if one is set prior to calling render() - // for detached overlays. - if (getPosition() != OverlayPosition.DETACHED || getPreferredLocation() != null) + // OverlayRenderer sets the overlay bounds to where it would like the overlay to render at prior to calling + // render(). If the overlay has a preferred location or position set we update the widget position to that. + if (getPreferredLocation() != null || getPreferredPosition() != null) { // The widget relative pos is relative to the parent widget.setRelativeX(bounds.x - parent.x); @@ -188,9 +188,8 @@ public class WidgetOverlay extends Overlay } @Override - public void reset() + public void revalidate() { - super.reset(); // Revalidate must be called on the client thread, so defer til next frame revalidate = true; } diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_prayer.json b/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_prayer.json index 2e74c93d0c..8ef26c4797 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_prayer.json +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_prayer.json @@ -11,6 +11,10 @@ { "name": "Chaos Altar (700%)", "value": 6 + }, + { + "name": "Morytania Diary 3 Shades(150%)", + "value": 0.5 } ], "actions": [ @@ -219,8 +223,7 @@ "level": 1, "icon": 3396, "name": "Loar Remains", - "xp": 33, - "ignoreBonus": true + "xp": 33 }, { "level": 1, @@ -274,8 +277,7 @@ "level": 1, "icon": 3398, "name": "Phrin Remains", - "xp": 46.5, - "ignoreBonus": true + "xp": 46.5 }, { "level": 1, @@ -287,8 +289,7 @@ "level": 1, "icon": 3400, "name": "Riyl Remains", - "xp": 59.5, - "ignoreBonus": true + "xp": 59.5 }, { "level": 1, @@ -312,8 +313,7 @@ "level": 1, "icon": 3402, "name": "Asyn Remains", - "xp": 82.5, - "ignoreBonus": true + "xp": 82.5 }, { "level": 1, @@ -325,8 +325,7 @@ "level": 1, "icon": 3404, "name": "Fiyr Remains", - "xp": 84, - "ignoreBonus": true + "xp": 84 }, { "level": 1, @@ -363,6 +362,12 @@ "icon": 22124, "name": "Superior Dragon Bones", "xp": 150 + }, + { + "level": 1, + "icon": 25419, + "name": "Urium Remains", + "xp": 120 } ] }