Skip to content

Commit

Permalink
Make VarbitChanged only fire once, after everything has settled
Browse files Browse the repository at this point in the history
  • Loading branch information
abextm committed May 11, 2018
1 parent 564f54a commit c9d0abc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ public interface Client extends GameEngine
@VisibleForDevtools
void setVarbitValue(int varbit, int value);

boolean shouldPostVarbitEvent();

HashTable getWidgetFlags();

HashTable getComponentTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.runelite.api.events.PostItemComposition;
import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.SetMessage;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP;
import net.runelite.client.Notifier;
Expand Down Expand Up @@ -102,6 +103,7 @@ public class Hooks
private static final GameTick tick = new GameTick();
private static final DrawManager renderHooks = injector.getInstance(DrawManager.class);
private static final Notifier notifier = injector.getInstance(Notifier.class);
private static final VarbitChanged varbitChanged = new VarbitChanged();

private static Dimension lastStretchedDimensions;
private static BufferedImage stretchedImage;
Expand All @@ -116,6 +118,11 @@ public static void clientMainLoop(Client client, boolean arg1)
{
shouldProcessGameTick = false;

if (client.shouldPostVarbitEvent())
{
eventBus.post(varbitChanged);
}

_deferredEventBus.replay();

eventBus.post(tick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.ResizeableChanged;
import net.runelite.api.events.UsernameChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.FieldHook;
Expand Down Expand Up @@ -129,6 +128,9 @@ public abstract class RSClientMixin implements RSClient
@Inject
private static int inventoryDragDelay;

@Inject
private static boolean hasVarbitChanged;

@Inject
@Override
public boolean isInterpolatePlayerAnimations()
Expand Down Expand Up @@ -815,8 +817,16 @@ public static void onGrandExchangeOffersChanged(int idx)
@Inject
public static void settingsChanged(int idx)
{
VarbitChanged varbitChanged = new VarbitChanged();
eventBus.post(varbitChanged);
hasVarbitChanged = true;
}

@Inject
@Override
public boolean shouldPostVarbitEvent()
{
boolean ret = hasVarbitChanged;
hasVarbitChanged = false;
return ret;
}

@FieldHook("isResized")
Expand Down

0 comments on commit c9d0abc

Please sign in to comment.