Skip to content

Commit

Permalink
mixins: move widget open event to loadWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Mar 29, 2018
1 parent f3e7fa0 commit b0b5ef8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@
@Data
public class WidgetOpened
{
private int parentId;
private int groupId;
private int autoClose;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
import net.runelite.api.mixins.Shadow;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
import static net.runelite.client.callback.Hooks.eventBus;
import net.runelite.rs.api.RSClanMemberManager;
import net.runelite.rs.api.RSClient;
Expand Down Expand Up @@ -507,25 +509,28 @@ public SpritePixels createItemSprite(int itemId, int quantity, int border, int s
client.setMenuEntries(entries);
}

@Copy("openWidget")
public static WidgetNode rs$openWidget(int parentId, int groupId, int autoClose)
@Copy("loadWidget")
public static boolean rs$loadWidget(int widgetId)
{
throw new RuntimeException();
}

@Replace("openWidget")
public static WidgetNode rl$openWidget(int parentId, int groupId, int autoClose)
@Replace("loadWidget")
public static boolean rl$loadWidget(int widgetId)
{
MenuEntry[] entries = client.getMenuEntries();
WidgetNode widgetNode = rs$openWidget(parentId, groupId, autoClose);
client.setMenuEntries(entries);
RSWidget[][] widgets = client.getWidgets();
boolean loadedBefore = widgets != null && widgets[widgetId] != null;

boolean loaded = rs$loadWidget(widgetId);

if (!loadedBefore && loaded)
{
WidgetOpened event = new WidgetOpened();
event.setGroupId(widgetId);
eventBus.post(event);
}

WidgetOpened event = new WidgetOpened();
event.setParentId(parentId);
event.setGroupId(groupId);
event.setAutoClose(autoClose);
eventBus.post(event);
return widgetNode;
return loaded;
}

@FieldHook("skillExperiences")
Expand Down

0 comments on commit b0b5ef8

Please sign in to comment.