Search in sources :

Example 21 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class MotherlodeSackOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);
    panelComponent.getLines().clear();
    if (sack != null) {
        sack.setHidden(true);
        if (config.showSack()) {
            panelComponent.getLines().add(new PanelComponent.Line("Pay-dirt in sack:", String.valueOf(client.getSetting(Varbits.SACK_NUMBER))));
        }
    }
    return panelComponent.render(graphics);
}
Also used : Widget(net.runelite.api.widgets.Widget) PanelComponent(net.runelite.client.ui.overlay.components.PanelComponent)

Example 22 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class MouseHighlightOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (client.isMenuOpen()) {
        return null;
    }
    MenuEntry[] menuEntries = client.getMenuEntries();
    int last = menuEntries.length - 1;
    if (last < 0) {
        return null;
    }
    MenuEntry menuEntry = menuEntries[last];
    String target = menuEntry.getTarget();
    String option = menuEntry.getOption();
    if (Strings.isNullOrEmpty(option)) {
        return null;
    }
    // Trivial options that don't need to be highlighted, add more as they appear.
    switch(option) {
        case "Walk here":
        case "Cancel":
        case "Continue":
            return null;
        case "Move":
            // Hide overlay on sliding puzzle boxes
            if (target.contains("Sliding piece")) {
                return null;
            }
    }
    final int widgetId = menuEntry.getParam1();
    final int groupId = WidgetInfo.TO_GROUP(widgetId);
    final int childId = WidgetInfo.TO_CHILD(widgetId);
    final Widget widget = client.getWidget(groupId, childId);
    if (!config.uiTooltip() && widget != null) {
        return null;
    }
    if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) {
        return null;
    }
    if (widget != null) {
        // If this varc is set, some CS is showing tooltip
        Varcs varcs = client.getVarcs();
        int tooltipTimeout = varcs.getIntVar(VarClient.TOOLTIP_TIMEOUT);
        if (tooltipTimeout > client.getGameCycle()) {
            return null;
        }
    }
    tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target)));
    return null;
}
Also used : MenuEntry(net.runelite.api.MenuEntry) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) Widget(net.runelite.api.widgets.Widget) Varcs(net.runelite.api.Varcs)

Example 23 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class ReorderPrayersPlugin method onDraggingWidgetChanged.

@Subscribe
public void onDraggingWidgetChanged(DraggingWidgetChanged event) {
    // is dragging widget and mouse button released
    if (event.isDraggingWidget() && client.getMouseCurrentButton() == 0) {
        Widget draggedWidget = client.getDraggedWidget();
        Widget draggedOnWidget = client.getDraggedOnWidget();
        if (draggedWidget != null && draggedOnWidget != null) {
            int draggedGroupId = WidgetInfo.TO_GROUP(draggedWidget.getId());
            int draggedOnGroupId = WidgetInfo.TO_GROUP(draggedOnWidget.getId());
            if (draggedGroupId != WidgetID.PRAYER_GROUP_ID || draggedOnGroupId != WidgetID.PRAYER_GROUP_ID || draggedOnWidget.getWidth() != PRAYER_WIDTH || draggedOnWidget.getHeight() != PRAYER_HEIGHT) {
                return;
            }
            // reset dragged on widget to prevent sending a drag widget packet to the server
            client.setDraggedOnWidget(null);
            int fromPrayerIndex = getPrayerIndex(draggedWidget);
            int toPrayerIndex = getPrayerIndex(draggedOnWidget);
            Prayer tmp = prayerOrder[toPrayerIndex];
            prayerOrder[toPrayerIndex] = prayerOrder[fromPrayerIndex];
            prayerOrder[fromPrayerIndex] = tmp;
            save();
        }
    }
}
Also used : Widget(net.runelite.api.widgets.Widget) Prayer(net.runelite.api.Prayer) Subscribe(com.google.common.eventbus.Subscribe)

Example 24 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class ReorderPrayersPlugin method reorderPrayers.

private void reorderPrayers() {
    if (client.getGameState() != GameState.LOGGED_IN) {
        return;
    }
    PrayerTabState prayerTabState = getPrayerTabState();
    if (prayerTabState == PrayerTabState.PRAYERS) {
        List<Widget> prayerWidgets = PRAYER_WIDGET_INFO_LIST.stream().map(client::getWidget).filter(Objects::nonNull).collect(Collectors.toList());
        if (prayerWidgets.size() != PRAYER_WIDGET_INFO_LIST.size()) {
            return;
        }
        for (int index = 0; index < prayerOrder.length; index++) {
            Prayer prayer = prayerOrder[index];
            Widget prayerWidget = prayerWidgets.get(prayer.ordinal());
            int widgetConfig = prayerWidget.setClickMask();
            if (config.unlockPrayerReordering()) {
                // allow dragging of this widget
                widgetConfig |= DRAG;
                // allow this widget to be dragged on
                widgetConfig |= DRAG_ON;
            } else {
                // remove drag flag
                widgetConfig &= ~DRAG;
                // remove drag on flag
                widgetConfig &= ~DRAG_ON;
            }
            prayerWidget.setClickMask(widgetConfig);
            int x = index % PRAYER_COLUMN_COUNT;
            int y = index / PRAYER_COLUMN_COUNT;
            int widgetX = x * PRAYER_X_OFFSET;
            int widgetY = y * PRAYER_Y_OFFSET;
            setWidgetPosition(prayerWidget, widgetX, widgetY);
        }
    } else if (prayerTabState == PrayerTabState.QUICK_PRAYERS) {
        Widget prayersContainer = client.getWidget(WidgetInfo.QUICK_PRAYER_PRAYERS);
        if (prayersContainer == null) {
            return;
        }
        Widget[] prayerWidgets = prayersContainer.getDynamicChildren();
        if (prayerWidgets == null || prayerWidgets.length != PRAYER_COUNT * 3) {
            return;
        }
        for (int index = 0; index < prayerOrder.length; index++) {
            Prayer prayer = prayerOrder[index];
            int x = index % PRAYER_COLUMN_COUNT;
            int y = index / PRAYER_COLUMN_COUNT;
            Widget prayerWidget = prayerWidgets[QUICK_PRAYER_CHILD_IDS.get(prayer.ordinal())];
            setWidgetPosition(prayerWidget, x * PRAYER_X_OFFSET, y * PRAYER_Y_OFFSET);
            int childId = PRAYER_COUNT + 2 * prayer.ordinal();
            Widget prayerSpriteWidget = prayerWidgets[childId];
            setWidgetPosition(prayerSpriteWidget, QUICK_PRAYER_SPRITE_X_OFFSET + x * PRAYER_X_OFFSET, QUICK_PRAYER_SPRITE_Y_OFFSET + y * PRAYER_Y_OFFSET);
            Widget prayerToggleWidget = prayerWidgets[childId + 1];
            setWidgetPosition(prayerToggleWidget, x * PRAYER_X_OFFSET, y * PRAYER_Y_OFFSET);
        }
    }
}
Also used : Widget(net.runelite.api.widgets.Widget) Prayer(net.runelite.api.Prayer)

Example 25 with Widget

use of net.runelite.api.widgets.Widget in project runelite by runelite.

the class NightmareZoneOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!plugin.isInNightmareZone() || !config.moveOverlay()) {
        if (absorptionCounter != null) {
            removeAbsorptionCounter();
            // Restore original widget
            Widget nmzWidget = client.getWidget(WidgetInfo.NIGHTMARE_ZONE);
            if (nmzWidget != null) {
                nmzWidget.setHidden(false);
            }
        }
        return null;
    }
    Widget nmzWidget = client.getWidget(WidgetInfo.NIGHTMARE_ZONE);
    if (nmzWidget != null) {
        nmzWidget.setHidden(true);
    }
    renderAbsorptionCounter();
    panelComponent.getLines().clear();
    panelComponent.getLines().add(new PanelComponent.Line("Points: ", Color.WHITE, StackFormatter.formatNumber(client.getSetting(Varbits.NMZ_POINTS)), Color.WHITE));
    return panelComponent.render(graphics);
}
Also used : Widget(net.runelite.api.widgets.Widget) PanelComponent(net.runelite.client.ui.overlay.components.PanelComponent)

Aggregations

Widget (net.runelite.api.widgets.Widget)56 Rectangle (java.awt.Rectangle)10 WidgetItem (net.runelite.api.widgets.WidgetItem)10 ArrayList (java.util.ArrayList)9 Subscribe (com.google.common.eventbus.Subscribe)7 Inject (net.runelite.api.mixins.Inject)6 RSWidget (net.runelite.rs.api.RSWidget)6 Point (net.runelite.api.Point)5 WidgetHiddenChanged (net.runelite.api.events.WidgetHiddenChanged)5 PanelComponent (net.runelite.client.ui.overlay.components.PanelComponent)5 Test (org.junit.Test)5 FontMetrics (java.awt.FontMetrics)4 Rectangle2D (java.awt.geom.Rectangle2D)4 Consumer (java.util.function.Consumer)4 LocalPoint (net.runelite.api.coords.LocalPoint)4 ItemComposition (net.runelite.api.ItemComposition)3 WidgetInfo (net.runelite.api.widgets.WidgetInfo)3 Color (java.awt.Color)2 BufferedImage (java.awt.image.BufferedImage)2 Matcher (java.util.regex.Matcher)2