Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2021-11-17 16:35:59 +01:00
28 changed files with 154 additions and 116 deletions

View File

@@ -100,7 +100,7 @@ public class EventBus
{
final ImmutableMultimap.Builder<Class<?>, Subscriber> builder = ImmutableMultimap.builder();
builder.putAll(subscribers);
builder.orderValuesBy(Comparator.comparing(Subscriber::getPriority).reversed()
builder.orderValuesBy(Comparator.comparingDouble(Subscriber::getPriority).reversed()
.thenComparing(s -> s.object.getClass().getName()));
for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
@@ -168,7 +168,7 @@ public class EventBus
{
final ImmutableMultimap.Builder<Class<?>, Subscriber> builder = ImmutableMultimap.builder();
builder.putAll(subscribers);
builder.orderValuesBy(Comparator.comparing(Subscriber::getPriority).reversed()
builder.orderValuesBy(Comparator.comparingDouble(Subscriber::getPriority).reversed()
.thenComparing(s -> s.object.getClass().getName()));
Subscriber sub = new Subscriber(subFn, null, priority, (Consumer<Object>) subFn);

View File

@@ -546,8 +546,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
Widget[] containerChildren = itemContainer.getDynamicChildren();
// sort the child array as the items are not in the displayed order
Arrays.sort(containerChildren, Comparator.comparing(Widget::getOriginalY)
.thenComparing(Widget::getOriginalX));
Arrays.sort(containerChildren, Comparator.comparingInt(Widget::getOriginalY)
.thenComparingInt(Widget::getOriginalX));
for (Widget child : containerChildren)
{

View File

@@ -436,9 +436,9 @@ class WidgetInspector extends DevToolsFrame
parent = Stream.of(roots)
.filter(w -> w.getType() == WidgetType.LAYER && w.getContentType() == 0 && !w.isSelfHidden())
.sorted(Comparator.comparing((Widget w) -> w.getRelativeX() + w.getRelativeY())
.sorted(Comparator.comparingInt((Widget w) -> w.getRelativeX() + w.getRelativeY())
.reversed()
.thenComparing(Widget::getId)
.thenComparingInt(Widget::getId)
.reversed())
.findFirst().get();
x = 4;

View File

@@ -462,14 +462,14 @@ public class FishingPlugin extends Plugin
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
fishingSpots.sort(
Comparator.comparing(
Comparator.comparingInt(
// Negate to have the furthest first
(NPC npc) -> -npc.getLocalLocation().distanceTo(cameraPoint))
// Order by position
.thenComparing(NPC::getLocalLocation, Comparator.comparing(LocalPoint::getX)
.thenComparing(LocalPoint::getY))
.thenComparing(NPC::getLocalLocation, Comparator.comparingInt(LocalPoint::getX)
.thenComparingInt(LocalPoint::getY))
// And then by id
.thenComparing(NPC::getId)
.thenComparingInt(NPC::getId)
);
}
}

View File

@@ -394,9 +394,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
this.gl = glContext.getGL().getGL4();
final boolean unlockFps = this.config.unlockFps();
client.setUnlockedFps(unlockFps);
gl.setSwapInterval(unlockFps ? -1 : 0);
setupSyncMode();
if (log.isDebugEnabled())
{
@@ -556,18 +554,43 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
{
if (configChanged.getGroup().equals(GpuPluginConfig.GROUP))
{
if (configChanged.getKey().equals("unlockFps"))
if (configChanged.getKey().equals("unlockFps")
|| configChanged.getKey().equals("vsyncMode")
|| configChanged.getKey().equals("fpsTarget"))
{
boolean unlockFps = Boolean.parseBoolean(configChanged.getNewValue());
clientThread.invokeLater(() ->
{
client.setUnlockedFps(unlockFps);
invokeOnMainThread(() -> gl.setSwapInterval(unlockFps ? -1 : 0));
});
log.debug("Rebuilding sync mode");
clientThread.invokeLater(() -> invokeOnMainThread(this::setupSyncMode));
}
}
}
private void setupSyncMode()
{
final boolean unlockFps = config.unlockFps();
client.setUnlockedFps(unlockFps);
// Without unlocked fps, the client manages sync on its 20ms timer
GpuPluginConfig.SyncMode syncMode = unlockFps
? this.config.syncMode()
: GpuPluginConfig.SyncMode.OFF;
switch (syncMode)
{
case ON:
gl.setSwapInterval(1);
client.setUnlockedFpsTarget(0);
break;
case OFF:
gl.setSwapInterval(0);
client.setUnlockedFpsTarget(config.fpsTarget()); // has no effect with unlockFps=false
break;
case ADAPTIVE:
gl.setSwapInterval(-1);
client.setUnlockedFpsTarget(0);
break;
}
}
private void initProgram() throws ShaderException
{
String versionHeader = OSType.getOSType() == OSType.Linux ? LINUX_VERSION_HEADER : WINDOWS_VERSION_HEADER;

View File

@@ -159,4 +159,37 @@ public interface GpuPluginConfig extends Config
{
return false;
}
enum SyncMode
{
OFF,
ON,
ADAPTIVE
}
@ConfigItem(
keyName = "vsyncMode",
name = "Vsync Mode",
description = "Method to synchronize frame rate with refresh rate",
position = 11
)
default SyncMode syncMode()
{
return SyncMode.ADAPTIVE;
}
@ConfigItem(
keyName = "fpsTarget",
name = "FPS Target",
description = "Target FPS when unlock FPS is enabled and Vsync mode is OFF",
position = 12
)
@Range(
min = 1,
max = 999
)
default int fpsTarget()
{
return 60;
}
}

View File

@@ -72,7 +72,7 @@ public class SaradominBrew implements Effect
).toArray(StatChange[]::new));
changes.setPositivity(Stream.of(changes.getStatChanges())
.map(sc -> sc.getPositivity())
.max(Comparator.comparing(Enum::ordinal)).get());
.max(Comparator.naturalOrder()).get());
return changes;
}
}

View File

@@ -68,7 +68,9 @@ public class SuperRestore implements Effect
return calc.effect(client);
})
).toArray(StatChange[]::new));
changes.setPositivity(Stream.of(changes.getStatChanges()).map(sc -> sc.getPositivity()).max(Comparator.comparing(Enum::ordinal)).get());
changes.setPositivity(Stream.of(changes.getStatChanges())
.map(sc -> sc.getPositivity())
.max(Comparator.naturalOrder()).get());
return changes;
}

View File

@@ -61,7 +61,7 @@ public class CastleWarsBandage implements Effect
changes.setStatChanges(new StatChange[]{hitPoints, runEnergy});
changes.setPositivity(Stream.of(changes.getStatChanges())
.map(StatChange::getPositivity)
.max(Comparator.comparing(Enum::ordinal)).get());
.max(Comparator.naturalOrder()).get());
return changes;
}

View File

@@ -418,7 +418,7 @@ public class MusicPlugin extends Plugin
if (tracks == null)
{
tracks = Arrays.stream(musicList.getDynamicChildren())
.sorted(Comparator.comparing(Widget::getRelativeY))
.sorted(Comparator.comparingInt(Widget::getRelativeY))
.collect(Collectors.toList());
}

View File

@@ -336,7 +336,7 @@ public class QuestListPlugin extends Plugin
{
// Find all of the widgets that we care about, sorting by their Y value
quests = Arrays.stream(list.getDynamicChildren())
.sorted(Comparator.comparing(Widget::getRelativeY))
.sorted(Comparator.comparingInt(Widget::getRelativeY))
.filter(w -> !QUEST_HEADERS.contains(w.getText()))
.map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase()))
.collect(Collectors.toList());

View File

@@ -72,7 +72,8 @@ public class SpecialCounterPlugin extends Plugin
{
private static final Set<Integer> IGNORED_NPCS = ImmutableSet.of(
NpcID.DARK_ENERGY_CORE, NpcID.ZOMBIFIED_SPAWN, NpcID.ZOMBIFIED_SPAWN_8063,
NpcID.COMBAT_DUMMY, NpcID.UNDEAD_COMBAT_DUMMY
NpcID.COMBAT_DUMMY, NpcID.UNDEAD_COMBAT_DUMMY,
NpcID.SKELETON_HELLHOUND_6613, NpcID.GREATER_SKELETON_HELLHOUND
);
private static final Set<Integer> RESET_ON_LEAVE_INSTANCED_REGIONS = ImmutableSet.of(

View File

@@ -29,9 +29,11 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("timestamp")
@ConfigGroup(TimestampConfig.GROUP)
public interface TimestampConfig extends Config
{
String GROUP = "timestamp";
@ConfigItem(
keyName = "opaqueTimestamp",
name = "Timestamps (opaque)",

View File

@@ -38,11 +38,11 @@ import net.runelite.api.Client;
import net.runelite.api.MessageNode;
import net.runelite.api.ScriptID;
import net.runelite.api.Varbits;
import net.runelite.api.events.ScriptPreFired;
import net.runelite.client.events.ConfigChanged;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.ColorUtil;
@@ -58,14 +58,15 @@ public class TimestampPlugin extends Plugin
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
private TimestampConfig config;
@Getter
private SimpleDateFormat formatter;
private MessageNode currentlyBuildingMessage = null;
@Provides
public TimestampConfig provideConfig(final ConfigManager configManager)
{
@@ -87,9 +88,18 @@ public class TimestampPlugin extends Plugin
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("timestamp") && event.getKey().equals("format"))
if (event.getGroup().equals(TimestampConfig.GROUP))
{
updateFormatter();
switch (event.getKey())
{
case "format":
updateFormatter();
break;
case "opaqueTimestamp":
case "transparentTimestamp":
clientThread.invokeLater(() -> client.runScript(ScriptID.SPLITPM_CHANGED));
break;
}
}
}
@@ -102,51 +112,18 @@ public class TimestampPlugin extends Plugin
}
int uid = client.getIntStack()[client.getIntStackSize() - 1];
currentlyBuildingMessage = client.getMessages().get(uid);
}
final MessageNode messageNode = client.getMessages().get(uid);
assert messageNode != null : "chat message build for unknown message";
@Subscribe
private void onScriptPreFired(ScriptPreFired ev)
{
int numStringArgs;
int messagePrefixArg = 0;
switch (ev.getScriptId())
{
case ScriptID.CHATBOX_BUILD_LINE_WITHOUT_USER:
numStringArgs = 1;
break;
case ScriptID.CHATBOX_BUILD_LINE_WITH_USER:
numStringArgs = 2;
break;
case ScriptID.CHATBOX_BUILD_LINE_WITH_CLAN:
numStringArgs = 3;
break;
default:
return;
}
if (currentlyBuildingMessage == null)
{
return;
}
MessageNode messageNode = currentlyBuildingMessage;
currentlyBuildingMessage = null;
String[] stringStack = client.getStringStack();
int stringArgStart = client.getStringStackSize() - numStringArgs;
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault()) + " ";
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault());
Color timestampColour = getTimestampColour();
if (timestampColour != null)
{
timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
}
String segment = stringStack[stringArgStart + messagePrefixArg];
segment = timestamp + segment;
stringStack[stringArgStart + messagePrefixArg] = segment;
client.getStringStack()[client.getStringStackSize() - 1] = timestamp;
}
private Color getTimestampColour()

View File

@@ -282,7 +282,7 @@ public class ContainableFrame extends JFrame
{
return Arrays.stream(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices())
.map(GraphicsDevice::getDefaultConfiguration)
.max(Comparator.comparing(config ->
.max(Comparator.comparingInt(config ->
{
Rectangle intersection = config.getBounds().intersection(getBounds());
return intersection.width * intersection.height;

View File

@@ -3126,15 +3126,6 @@
3157,
3159
],
"monkey bones": [
3179,
3180,
3181,
3182,
3183,
3185,
3186
],
"barrel bomb": [
3218,
3219

View File

@@ -343,9 +343,9 @@ LABEL319:
jump LABEL1598
LABEL323:
iload 10
5031
chat_gethistoryex_byuid
istore 21
sstore 18
sstore 18 ; timestamp
istore 15
sstore 15
sstore 14
@@ -390,9 +390,11 @@ LABEL341:
jump LABEL1594
LABEL355:
iload 10 ; message uid
sload 18 ; message timestamp
sconst "chatMessageBuilding"
runelite_callback
pop_int ; pop uid
sstore 18 ; message timestamp
iload 11
switch
1: LABEL358

View File

@@ -381,9 +381,9 @@ LABEL344:
jump LABEL566
LABEL350:
iload 12
5031
chat_gethistoryex_byuid
istore 15
sstore 2
sstore 2 ; timestamp
istore 14
sstore 0
sstore 3
@@ -413,9 +413,11 @@ CHAT_FILTER:
jump LABEL562
LABEL368:
iload 12 ; message uid
sload 2 ; message timestamp
sconst "chatMessageBuilding"
runelite_callback
pop_int
pop_int
sstore 2 ; message timestamp
iload 18
switch
3: LABEL371

View File

@@ -1 +1 @@
B5F4C856AEC94322FC7E2981920A8982FE331A300DD36FA0872840B7FA5A4C01
030CB9830EAD6F61CFC5ED1CA60AE3434900998EFB8237E9C750321775312072

View File

@@ -122,7 +122,7 @@ LABEL89:
LABEL96:
clientclock
set_varc_int 384
invoke 2357
invoke 1445
iconst 1
if_icmpeq LABEL102
jump LABEL106
@@ -172,7 +172,7 @@ LABEL131:
LABEL138:
clientclock
set_varc_int 384
invoke 2357
invoke 1445
iconst 1
if_icmpeq LABEL144
jump LABEL148
@@ -217,15 +217,15 @@ LABEL169:
jump LABEL180
LABEL176:
iconst 1
iconst 39387174
iconst 39387162
if_sethide
jump LABEL235
LABEL180:
iconst 0
iconst 39387174
iconst 39387162
if_sethide
iconst 1
iconst 39387174
iconst 39387162
2308
get_varbit 6255
switch
@@ -235,38 +235,38 @@ LABEL180:
jump LABEL213
LABEL189:
iconst 1718
iconst 39387176
iconst 39387181
if_setgraphic
iconst 1
sconst "Toggle single-tap mode"
iconst 39387174
iconst 39387162
if_setop
jump LABEL220
LABEL197:
iconst 1717
iconst 39387176
iconst 39387181
if_setgraphic
iconst 1
sconst "Toggle tap-to-drop mode"
iconst 39387174
iconst 39387162
if_setop
jump LABEL220
LABEL205:
iconst 1716
iconst 39387176
iconst 39387181
if_setgraphic
iconst 1
sconst "Show Keyboard"
iconst 39387174
iconst 39387162
if_setop
jump LABEL220
LABEL213:
iconst 1715
iconst 39387176
iconst 39387181
if_setgraphic
iconst 1
sconst ""
iconst 39387174
iconst 39387162
if_setop
LABEL220:
get_varbit 6255
@@ -280,18 +280,18 @@ LABEL224:
jump LABEL232
LABEL228:
iconst 155
iconst 39387176
iconst 39387181
if_settrans
jump LABEL235
LABEL232:
iconst 0
iconst 39387176
iconst 39387181
if_settrans
LABEL235:
invoke 2581
get_varbit 6254
invoke 633
iconst 39387165
iconst 39387173
if_sethide
invoke 2526
pop_int

View File

@@ -1 +1 @@
1BB0517CD647510451A0AF5FC160252892F4C3627BED106FEDEE44E62027A2D4
CAF61FF2A3131623A421CCCC68914587A69044768DEB79432DA8A85937283F7B

View File

@@ -221,7 +221,7 @@ LABEL183:
if_icmpeq LABEL189
jump LABEL417
LABEL189:
invoke 2357
invoke 1445
iconst 1
if_icmpeq LABEL193
jump LABEL267