Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Owain van Brakel
2020-02-09 02:30:02 +01:00
13 changed files with 383 additions and 13 deletions

View File

@@ -214,7 +214,7 @@ public enum ItemMapping
BLACK_MASK, BLACK_MASK_I, BLACK_MASK_1, BLACK_MASK_1_I, BLACK_MASK_2, BLACK_MASK_2_I, BLACK_MASK_3, BLACK_MASK_3_I, BLACK_MASK_4, BLACK_MASK_4_I, BLACK_MASK_5,
BLACK_MASK_5_I, BLACK_MASK_6, BLACK_MASK_6_I, BLACK_MASK_7, BLACK_MASK_7_I, BLACK_MASK_8, BLACK_MASK_8_I, BLACK_MASK_9, BLACK_MASK_9_I, BLACK_MASK_10_I,
SLAYER_HELMET, SLAYER_HELMET_I, BLACK_SLAYER_HELMET, BLACK_SLAYER_HELMET_I, PURPLE_SLAYER_HELMET, PURPLE_SLAYER_HELMET_I, RED_SLAYER_HELMET, RED_SLAYER_HELMET_I,
GREEN_SLAYER_HELMET, GREEN_SLAYER_HELMET_I, TURQUOISE_SLAYER_HELMET, TURQUOISE_SLAYER_HELMET_I, HYDRA_SLAYER_HELMET, HYDRA_SLAYER_HELMET_I),
GREEN_SLAYER_HELMET, GREEN_SLAYER_HELMET_I, TURQUOISE_SLAYER_HELMET, TURQUOISE_SLAYER_HELMET_I, TWISTED_SLAYER_HELMET, TWISTED_SLAYER_HELMET_I, HYDRA_SLAYER_HELMET, HYDRA_SLAYER_HELMET_I),
// Pharaoh's Sceptres
ITEM_PHARAOHS_SCEPTRE_1(PHARAOHS_SCEPTRE, PHARAOHS_SCEPTRE_1),
@@ -232,6 +232,7 @@ public enum ItemMapping
ITEM_BOTTOMLESS_COMPOST_BUCKET(BOTTOMLESS_COMPOST_BUCKET, BOTTOMLESS_COMPOST_BUCKET_22997),
ITEM_BASILISK_JAW(BASILISK_JAW, NEITIZNOT_FACEGUARD),
ITEM_HELM_OF_NEITIZNOT(HELM_OF_NEITIZNOT, NEITIZNOT_FACEGUARD),
ITEM_TWISTED_HORNS(TWISTED_HORNS, TWISTED_SLAYER_HELMET, TWISTED_SLAYER_HELMET_I),
// Crystal items
ITEM_CRYSTAL_TOOL_SEED(CRYSTAL_TOOL_SEED, CRYSTAL_AXE, CRYSTAL_AXE_INACTIVE, CRYSTAL_HARPOON, CRYSTAL_HARPOON_INACTIVE, CRYSTAL_PICKAXE, CRYSTAL_PICKAXE_INACTIVE),

View File

@@ -612,6 +612,35 @@ public class ClientUI
{
OSXUtil.requestFocus();
}
// The workaround for Windows is to minimise and then un-minimise the client to bring
// it to the front because java.awt.Window#toFront doesn't work reliably.
// See https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front/7435722#7435722
else if (OSType.getOSType() == OSType.Windows && !frame.isFocused())
{
SwingUtilities.invokeLater(() ->
{
if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH)
{
frame.setExtendedState(JFrame.ICONIFIED);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
else
{
// If the client is snapped to the top and bottom edges of the screen, setExtendedState will
// will reset it so setSize and setLocation ensure that the client doesn't move or resize.
// It is done this way because Windows does not support JFrame.MAXIMIZED_VERT
int x = frame.getLocation().x;
int y = frame.getLocation().y;
int width = frame.getWidth();
int height = frame.getHeight();
frame.setExtendedState(JFrame.ICONIFIED);
frame.setExtendedState(JFrame.NORMAL);
frame.setLocation(x, y);
frame.setSize(width, height);
}
});
}
frame.requestFocus();
giveClientFocus();

View File

@@ -28,13 +28,16 @@ import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Insets;
import java.awt.SecondaryLoop;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -60,6 +63,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
@@ -486,4 +490,54 @@ public class SwingUtil
EventQueue.invokeAndWait(r);
}
}
/**
* Removes all of a component's children faster than calling removeAll() on it in many cases
*/
public static void fastRemoveAll(Container c)
{
// If we are not on the EDT this will deadlock, in addition to being totally unsafe
assert SwingUtilities.isEventDispatchThread();
// when a component is removed it has to be resized for some reason, but only if it's valid
// so we make sure to invalidate everything before removing it
c.invalidate();
for (int i = 0; i < c.getComponentCount(); i++)
{
Component ic = c.getComponent(i);
// removeAll and removeNotify are both recursive, so we have to recurse before them
if (ic instanceof Container)
{
fastRemoveAll((Container) ic);
}
// each removeNotify needs to remove anything from the event queue that is for that widget
// this however requires taking a lock, and is moderately slow, so we just execute all of
// those events with a secondary event loop
pumpPendingEvents();
// call removeNotify early; this is most of the work in removeAll, and generates events that
// the next secondaryLoop will pickup
ic.removeNotify();
}
// Actually remove anything
c.removeAll();
}
/**
* Run any events currently in the event queue
*/
public static void pumpPendingEvents()
{
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
if (eq.peekEvent() != null)
{
SecondaryLoop l = eq.createSecondaryLoop();
SwingUtilities.invokeLater(l::exit);
l.enter();
}
}
}