Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2021-08-30 07:21:12 +02:00
12 changed files with 466 additions and 424 deletions

View File

@@ -188,7 +188,7 @@ public class SessionManager
} }
catch (IOException ex) 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 accountSession = null; // No more account
@@ -227,7 +227,7 @@ public class SessionManager
@Subscribe @Subscribe
public void onLoginResponse(LoginResponse loginResponse) public void onLoginResponse(LoginResponse loginResponse)
{ {
log.debug("Now logged in as {}", loginResponse.getUsername()); log.debug("Now signed in as {}", loginResponse.getUsername());
AccountSession session = getAccountSession(); AccountSession session = getAccountSession();
session.setUsername(loginResponse.getUsername()); session.setUsername(loginResponse.getUsername());

View File

@@ -75,14 +75,14 @@ public class AccountPlugin extends Plugin
loginButton = NavigationButton.builder() loginButton = NavigationButton.builder()
.tab(false) .tab(false)
.icon(LOGIN_IMAGE) .icon(LOGIN_IMAGE)
.tooltip("Log in to RuneLite") .tooltip("Sign in to RuneLite")
.onClick(this::loginClick) .onClick(this::loginClick)
.build(); .build();
logoutButton = NavigationButton.builder() logoutButton = NavigationButton.builder()
.tab(false) .tab(false)
.icon(LOGOUT_IMAGE) .icon(LOGOUT_IMAGE)
.tooltip("Log out of RuneLite") .tooltip("Sign out of RuneLite")
.onClick(this::logoutClick) .onClick(this::logoutClick)
.build(); .build();
@@ -113,7 +113,7 @@ public class AccountPlugin extends Plugin
private void logoutClick() private void logoutClick()
{ {
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, 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)) JOptionPane.YES_NO_OPTION))
{ {
executor.execute(sessionManager::logout); executor.execute(sessionManager::logout);

View File

@@ -189,7 +189,7 @@ public class InfoPanel extends PluginPanel
syncPanel = buildLinkPanel(IMPORT_ICON, "Import signed-out", "settings", () -> syncPanel = buildLinkPanel(IMPORT_ICON, "Import signed-out", "settings", () ->
{ {
final int result = JOptionPane.showOptionDialog(syncPanel, final int result = JOptionPane.showOptionDialog(syncPanel,
"<html>This will overwrite your settings with settings from your local profile, which<br/>is the profile used when not logged into RuneLite with a RuneLite account.</html>", "<html>This will overwrite your settings with settings from your local profile, which<br/>is the profile used when not signed into RuneLite with a RuneLite account.</html>",
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
null, new String[]{"Yes", "No"}, "No"); null, new String[]{"Yes", "No"}, "No");
@@ -303,14 +303,14 @@ public class InfoPanel extends PluginPanel
{ {
emailLabel.setContentType("text/plain"); emailLabel.setContentType("text/plain");
emailLabel.setText(name); emailLabel.setText(name);
loggedLabel.setText("Logged in as"); loggedLabel.setText("Signed in as");
actionsContainer.add(syncPanel, 0); actionsContainer.add(syncPanel, 0);
} }
else else
{ {
emailLabel.setContentType("text/html"); emailLabel.setContentType("text/html");
emailLabel.setText("<a href=\"" + RUNELITE_LOGIN + "\">Login</a> to sync settings to the cloud."); emailLabel.setText("<a href=\"" + RUNELITE_LOGIN + "\">Sign in</a> to sync settings to the cloud.");
loggedLabel.setText("Not logged in"); loggedLabel.setText("Not signed in");
actionsContainer.remove(syncPanel); actionsContainer.remove(syncPanel);
} }
} }

View File

@@ -92,7 +92,7 @@ public interface LootTrackerConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "syncPanel", keyName = "syncPanel",
name = "Synchronize panel contents", name = "Synchronize panel contents",
description = "Synchronize your local loot tracker with your server data (requires being logged in).<br/>" + description = "Synchronize your local loot tracker with your server data (requires being signed in).<br/>" +
" This means the panel is filled with portions of your remote data on startup<br/>" + " This means the panel is filled with portions of your remote data on startup<br/>" +
" and deleting data in the panel also deletes it on the server." " and deleting data in the panel also deletes it on the server."
) )

View File

@@ -46,6 +46,9 @@ import net.runelite.client.util.SwingUtil;
@Getter @Getter
public class TimeablePanel<T> extends JPanel public class TimeablePanel<T> 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 T timeable;
private final JLabel icon = new JLabel(); private final JLabel icon = new JLabel();
private final JLabel farmingContractIcon = new JLabel(); private final JLabel farmingContractIcon = new JLabel();
@@ -84,13 +87,10 @@ public class TimeablePanel<T> extends JPanel
infoPanel.add(text); infoPanel.add(text);
infoPanel.add(estimate); 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.setPreferredSize(new Dimension(30, 16));
notifyButton.setBorder(new EmptyBorder(0, 0, 0, 10)); notifyButton.setBorder(new EmptyBorder(0, 0, 0, 10));
notifyButton.setIcon(notifyIcon); notifyButton.setIcon(NOTIFY_ICON);
notifyButton.setSelectedIcon(notifySelectedIcon); notifyButton.setSelectedIcon(NOTIFY_SELECTED_ICON);
SwingUtil.removeButtonDecorations(notifyButton); SwingUtil.removeButtonDecorations(notifyButton);
SwingUtil.addModalTooltip(notifyButton, "Disable notifications", "Enable notifications"); SwingUtil.addModalTooltip(notifyButton, "Disable notifications", "Enable notifications");

View File

@@ -311,8 +311,46 @@ class WorldTableRow extends JPanel
JPanel column = new JPanel(new BorderLayout()); JPanel column = new JPanel(new BorderLayout());
column.setBorder(new EmptyBorder(0, 5, 0, 5)); column.setBorder(new EmptyBorder(0, 5, 0, 5));
activityField = new JLabel(world.getActivity()); String activity = world.getActivity();
activityField = new JLabel(activity);
activityField.setFont(FontManager.getRunescapeSmallFont()); 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); column.add(activityField, BorderLayout.WEST);

View File

@@ -129,10 +129,7 @@ public abstract class Overlay implements LayoutableRenderableEntity
return null; return null;
} }
public void reset() public void revalidate()
{ {
setPreferredPosition(null);
setPreferredSize(null);
setPreferredLocation(null);
} }
} }

View File

@@ -289,8 +289,11 @@ public class OverlayManager
*/ */
public synchronized void resetOverlay(final Overlay overlay) public synchronized void resetOverlay(final Overlay overlay)
{ {
overlay.reset(); overlay.setPreferredPosition(null);
overlay.setPreferredSize(null);
overlay.setPreferredLocation(null);
saveOverlay(overlay); saveOverlay(overlay);
overlay.revalidate();
} }
synchronized void rebuildOverlayLayers() synchronized void rebuildOverlayLayers()

View File

@@ -289,25 +289,18 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
final Dimension dimension = bounds.getSize(); final Dimension dimension = bounds.getSize();
final Point preferredLocation = overlay.getPreferredLocation(); final Point preferredLocation = overlay.getPreferredLocation();
Point location; Point location;
Rectangle snapCorner = null;
// If the final position is not modified, layout it // If the final position is not modified, layout it
if (overlayPosition != OverlayPosition.DETACHED && (preferredLocation == null || overlay.getPreferredPosition() != null)) 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 final Point translation = OverlayUtil.transformPosition(overlayPosition, dimension); // offset from corner
// Target x/y to draw the overlay // Target x/y to draw the overlay
int destX = (int) snapCorner.getX() + translation.x; int destX = snapCorner.x + translation.x;
int destY = (int) snapCorner.getY() + translation.y; int destY = snapCorner.y + translation.y;
// Clamp the target position to ensure it is on screen or within parent bounds // Clamp the target position to ensure it is on screen or within parent bounds
location = clampOverlayLocation(destX, destY, dimension.width, dimension.height, overlay); 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 else
{ {
@@ -324,6 +317,12 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
safeRender(client, overlay, layer, graphics, location); 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 // Restore graphics2d properties prior to drawing bounds
graphics.setTransform(transform); graphics.setTransform(transform);
graphics.setStroke(stroke); graphics.setStroke(stroke);
@@ -703,7 +702,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
{ {
OverlayPosition position = snapCorners.fromBounds(snapCorner); OverlayPosition position = snapCorners.fromBounds(snapCorner);
if (position == currentManagedOverlay.getPosition()) if (position == getCorrectedOverlayPosition(currentManagedOverlay))
{ {
// overlay moves back to default position // overlay moves back to default position
position = null; position = null;
@@ -711,6 +710,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
currentManagedOverlay.setPreferredPosition(position); currentManagedOverlay.setPreferredPosition(position);
currentManagedOverlay.setPreferredLocation(null); // from dragging currentManagedOverlay.setPreferredLocation(null); // from dragging
currentManagedOverlay.revalidate();
break; break;
} }
} }

View File

@@ -30,6 +30,7 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.Shape; import java.awt.Shape;
import java.awt.Stroke; import java.awt.Stroke;
@@ -201,33 +202,32 @@ public class OverlayUtil
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 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(); // translate corner for padding and also based on where the overlay bounds are now
int sX = snapCorner.x, sY = snapCorner.y;
switch (position) switch (overlayPosition)
{ {
case DYNAMIC:
case TOOLTIP:
break;
case BOTTOM_LEFT: case BOTTOM_LEFT:
result.x += dimension.width + (dimension.width == 0 ? 0 : padding); sX = bounds.x + bounds.width + padding;
break; break;
case BOTTOM_RIGHT: case BOTTOM_RIGHT:
result.x -= dimension.width + (dimension.width == 0 ? 0 : padding); sX = bounds.x - padding;
break; break;
case TOP_LEFT: case TOP_LEFT:
case TOP_CENTER: case TOP_CENTER:
case CANVAS_TOP_RIGHT: case CANVAS_TOP_RIGHT:
case TOP_RIGHT: case TOP_RIGHT:
result.y += dimension.height + (dimension.height == 0 ? 0 : padding); sY = bounds.y + bounds.height + padding;
break; break;
case ABOVE_CHATBOX_RIGHT: case ABOVE_CHATBOX_RIGHT:
result.y -= dimension.height + (dimension.height == 0 ? 0 : padding); sY = bounds.y - padding;
break; break;
default:
throw new IllegalArgumentException();
} }
snapCorner.x = sX;
return result; snapCorner.y = sY;
} }
public static java.awt.Point transformPosition(OverlayPosition position, Dimension dimension) public static java.awt.Point transformPosition(OverlayPosition position, Dimension dimension)

View File

@@ -121,9 +121,9 @@ public class WidgetOverlay extends Overlay
assert widget != null; assert widget != null;
final Rectangle bounds = getBounds(); final Rectangle bounds = getBounds();
// OverlayRenderer sets the overlay bounds to the preferred location if one is set prior to calling render() // OverlayRenderer sets the overlay bounds to where it would like the overlay to render at prior to calling
// for detached overlays. // render(). If the overlay has a preferred location or position set we update the widget position to that.
if (getPosition() != OverlayPosition.DETACHED || getPreferredLocation() != null) if (getPreferredLocation() != null || getPreferredPosition() != null)
{ {
// The widget relative pos is relative to the parent // The widget relative pos is relative to the parent
widget.setRelativeX(bounds.x - parent.x); widget.setRelativeX(bounds.x - parent.x);
@@ -188,9 +188,8 @@ public class WidgetOverlay extends Overlay
} }
@Override @Override
public void reset() public void revalidate()
{ {
super.reset();
// Revalidate must be called on the client thread, so defer til next frame // Revalidate must be called on the client thread, so defer til next frame
revalidate = true; revalidate = true;
} }

View File

@@ -11,6 +11,10 @@
{ {
"name": "Chaos Altar (700%)", "name": "Chaos Altar (700%)",
"value": 6 "value": 6
},
{
"name": "Morytania Diary 3 Shades(150%)",
"value": 0.5
} }
], ],
"actions": [ "actions": [
@@ -219,8 +223,7 @@
"level": 1, "level": 1,
"icon": 3396, "icon": 3396,
"name": "Loar Remains", "name": "Loar Remains",
"xp": 33, "xp": 33
"ignoreBonus": true
}, },
{ {
"level": 1, "level": 1,
@@ -274,8 +277,7 @@
"level": 1, "level": 1,
"icon": 3398, "icon": 3398,
"name": "Phrin Remains", "name": "Phrin Remains",
"xp": 46.5, "xp": 46.5
"ignoreBonus": true
}, },
{ {
"level": 1, "level": 1,
@@ -287,8 +289,7 @@
"level": 1, "level": 1,
"icon": 3400, "icon": 3400,
"name": "Riyl Remains", "name": "Riyl Remains",
"xp": 59.5, "xp": 59.5
"ignoreBonus": true
}, },
{ {
"level": 1, "level": 1,
@@ -312,8 +313,7 @@
"level": 1, "level": 1,
"icon": 3402, "icon": 3402,
"name": "Asyn Remains", "name": "Asyn Remains",
"xp": 82.5, "xp": 82.5
"ignoreBonus": true
}, },
{ {
"level": 1, "level": 1,
@@ -325,8 +325,7 @@
"level": 1, "level": 1,
"icon": 3404, "icon": 3404,
"name": "Fiyr Remains", "name": "Fiyr Remains",
"xp": 84, "xp": 84
"ignoreBonus": true
}, },
{ {
"level": 1, "level": 1,
@@ -363,6 +362,12 @@
"icon": 22124, "icon": 22124,
"name": "Superior Dragon Bones", "name": "Superior Dragon Bones",
"xp": 150 "xp": 150
},
{
"level": 1,
"icon": 25419,
"name": "Urium Remains",
"xp": 120
} }
] ]
} }