Java Code Examples for net.runelite.api.widgets.Widget#getRelativeY()
The following examples show how to use
net.runelite.api.widgets.Widget#getRelativeY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombatLevelPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void appendAttackLevelRangeText() { final Widget wildernessLevelWidget = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL); if (wildernessLevelWidget == null) { return; } final String wildernessLevelText = wildernessLevelWidget.getText(); final Matcher m = WILDERNESS_LEVEL_PATTERN.matcher(wildernessLevelText); if (!m.matches() || WorldType.isPvpWorld(client.getWorldType())) { return; } final Widget skullContainer = client.getWidget(WidgetInfo.PVP_SKULL_CONTAINER); if (originalWildernessLevelTextPosition == -1) { originalWildernessLevelTextPosition = wildernessLevelWidget.getOriginalY(); } if (originalSkullContainerPosition == -1) { originalSkullContainerPosition = skullContainer.getRelativeY(); } final int wildernessLevel = Integer.parseInt(m.group(1)); final int combatLevel = client.getLocalPlayer().getCombatLevel(); wildernessLevelWidget.setText(wildernessLevelText + "<br>" + combatAttackRange(combatLevel, wildernessLevel)); wildernessLevelWidget.setOriginalY(WILDERNESS_LEVEL_TEXT_ADJUSTED_ORIGINAL_Y); skullContainer.setOriginalY(SKULL_CONTAINER_ADJUSTED_ORIGINAL_Y); clientThread.invoke(wildernessLevelWidget::revalidate); clientThread.invoke(skullContainer::revalidate); }
Example 2
Source File: ClueScrollPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget... toHighlight) { final Widget parent = client.getWidget(list); int averageCentralY = 0; int nonnullCount = 0; for (Widget widget : toHighlight) { if (widget != null) { averageCentralY += widget.getRelativeY() + widget.getHeight() / 2; nonnullCount += 1; } } if (nonnullCount == 0) { return; } averageCentralY /= nonnullCount; final int newScroll = Math.max(0, Math.min(parent.getScrollHeight(), averageCentralY - parent.getHeight() / 2)); client.runScript( ScriptID.UPDATE_SCROLLBAR, scrollbar.getId(), list.getId(), newScroll ); }
Example 3
Source File: ChatboxPerformancePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void fixDarkBackground() { int currOpacity = 256; int prevY = 0; Widget[] children = client.getWidget(WidgetInfo.CHATBOX_TRANSPARENT_BACKGROUND).getDynamicChildren(); Widget prev = null; for (Widget w : children) { if (w.getType() != WidgetType.RECTANGLE) { continue; } if (prev != null) { int relY = w.getRelativeY(); prev.setHeightMode(WidgetSizeMode.ABSOLUTE); prev.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); prev.setRelativeY(prevY); prev.setOriginalY(prev.getRelativeY()); prev.setHeight(relY - prevY); prev.setOriginalHeight(prev.getHeight()); prev.setOpacity(currOpacity); } prevY = w.getRelativeY(); currOpacity -= 3; // Rough number, can't get exactly the same as Jagex because of rounding prev = w; } if (prev != null) { prev.setOpacity(currOpacity); } }
Example 4
Source File: ChatboxPerformancePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void fixWhiteLines(boolean upperLine) { int currOpacity = 256; int prevWidth = 0; Widget[] children = client.getWidget(WidgetInfo.CHATBOX_TRANSPARENT_LINES).getDynamicChildren(); Widget prev = null; for (Widget w : children) { if (w.getType() != WidgetType.RECTANGLE) { continue; } if ((w.getRelativeY() == 0 && !upperLine) || (w.getRelativeY() != 0 && upperLine)) { continue; } if (prev != null) { int width = w.getWidth(); prev.setWidthMode(WidgetSizeMode.ABSOLUTE); prev.setRelativeX(width); prev.setOriginalX(width); prev.setWidth(prevWidth - width); prev.setOriginalWidth(prev.getWidth()); prev.setOpacity(currOpacity); } prevWidth = w.getWidth(); currOpacity -= upperLine ? 3 : 4; // Rough numbers, can't get exactly the same as Jagex because of rounding prev = w; } if (prev != null) { prev.setOpacity(currOpacity); } }
Example 5
Source File: CombatLevelPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void appendAttackLevelRangeText() { final Widget wildernessLevelWidget = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL); if (wildernessLevelWidget == null) { return; } final String wildernessLevelText = wildernessLevelWidget.getText(); final Matcher m = WILDERNESS_LEVEL_PATTERN.matcher(wildernessLevelText); if (!m.matches() || WorldType.isPvpWorld(client.getWorldType())) { return; } final Widget skullContainer = client.getWidget(WidgetInfo.PVP_SKULL_CONTAINER); if (originalWildernessLevelTextPosition == -1) { originalWildernessLevelTextPosition = wildernessLevelWidget.getOriginalY(); } if (originalSkullContainerPosition == -1) { originalSkullContainerPosition = skullContainer.getRelativeY(); } final int wildernessLevel = Integer.parseInt(m.group(1)); final int combatLevel = client.getLocalPlayer().getCombatLevel(); wildernessLevelWidget.setText(wildernessLevelText + "<br>" + combatAttackRange(combatLevel, wildernessLevel)); wildernessLevelWidget.setOriginalY(WILDERNESS_LEVEL_TEXT_ADJUSTED_ORIGINAL_Y); skullContainer.setOriginalY(SKULL_CONTAINER_ADJUSTED_ORIGINAL_Y); clientThread.invoke(wildernessLevelWidget::revalidate); clientThread.invoke(skullContainer::revalidate); }
Example 6
Source File: ClueScrollPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget ... toHighlight) { final Widget parent = client.getWidget(list); int averageCentralY = 0; int nonnullCount = 0; for (Widget widget : toHighlight) { if (widget != null) { averageCentralY += widget.getRelativeY() + widget.getHeight() / 2; nonnullCount += 1; } } if (nonnullCount == 0) { return; } averageCentralY /= nonnullCount; final int newScroll = Math.max(0, Math.min(parent.getScrollHeight(), averageCentralY - parent.getHeight() / 2)); client.runScript( ScriptID.UPDATE_SCROLLBAR, scrollbar.getId(), list.getId(), newScroll ); }
Example 7
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateBounds() { Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); if (itemContainer == null) { return; } int height = itemContainer.getHeight(); // If player isn't using normal bank tabs if (itemContainer.getRelativeY() == 0) { height -= (TAB_HEIGHT + MARGIN); } bounds.setSize(TAB_WIDTH + MARGIN * 2, height); bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN); Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR); if (incinerator != null && !incinerator.isHidden()) { incinerator.setOriginalHeight(INCINERATOR_HEIGHT); incinerator.setOriginalWidth(INCINERATOR_WIDTH); incinerator.setOriginalY(INCINERATOR_HEIGHT); Widget child = incinerator.getDynamicChildren()[0]; child.setOriginalHeight(INCINERATOR_HEIGHT); child.setOriginalWidth(INCINERATOR_WIDTH); child.setWidthMode(WidgetSizeMode.ABSOLUTE); child.setHeightMode(WidgetSizeMode.ABSOLUTE); child.setType(WidgetType.GRAPHIC); child.setSpriteId(TabSprites.INCINERATOR.getSpriteId()); incinerator.revalidate(); bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight()); } if (upButton != null) { Point p = upButton.getCanvasLocation(); canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN); } }
Example 8
Source File: QuestListPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateFilter(String filter) { filter = filter.toLowerCase(); final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER); final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo); final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo); final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo); if (container == null || freeList == null || memberList == null || miniList == null) { return; } updateList(QuestContainer.FREE_QUESTS, filter); updateList(QuestContainer.MEMBER_QUESTS, filter); updateList(QuestContainer.MINI_QUESTS, filter); memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + (freeList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + (memberList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); // originalHeight is changed within updateList so revalidate all lists freeList.revalidate(); memberList.revalidate(); miniList.revalidate(); int y = miniList.getRelativeY() + miniList.getHeight() + 10; int newHeight; if (container.getScrollHeight() > 0) { newHeight = (container.getScrollY() * y) / container.getScrollHeight(); } else { newHeight = 0; } container.setScrollHeight(y); container.revalidateScroll(); clientThread.invokeLater(() -> client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.QUESTLIST_SCROLLBAR.getId(), WidgetInfo.QUESTLIST_CONTAINER.getId(), newHeight )); }
Example 9
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateBounds() { Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); if (itemContainer == null) { return; } int height = itemContainer.getHeight(); // If player isn't using normal bank tabs if (itemContainer.getRelativeY() == 0) { height -= (TAB_HEIGHT + MARGIN); } bounds.setSize(TAB_WIDTH + MARGIN * 2, height); bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN); Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR); if (incinerator != null && !incinerator.isHidden()) { incinerator.setOriginalHeight(INCINERATOR_HEIGHT); incinerator.setOriginalWidth(INCINERATOR_WIDTH); incinerator.setOriginalY(INCINERATOR_HEIGHT); Widget child = incinerator.getDynamicChildren()[0]; child.setOriginalHeight(INCINERATOR_HEIGHT); child.setOriginalWidth(INCINERATOR_WIDTH); child.setWidthMode(WidgetSizeMode.ABSOLUTE); child.setHeightMode(WidgetSizeMode.ABSOLUTE); child.setType(WidgetType.GRAPHIC); child.setSpriteId(TabSprites.INCINERATOR.getSpriteId()); incinerator.revalidate(); bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight()); } if (upButton != null) { Point p = upButton.getCanvasLocation(); canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN); } }
Example 10
Source File: QuestListPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateFilter(String filter) { filter = filter.toLowerCase(); final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER); final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo); final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo); final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo); if (container == null || freeList == null || memberList == null || miniList == null) { return; } updateList(QuestContainer.FREE_QUESTS, filter); updateList(QuestContainer.MEMBER_QUESTS, filter); updateList(QuestContainer.MINI_QUESTS, filter); memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + ENTRY_PADDING); miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + ENTRY_PADDING); // originalHeight is changed within updateList so revalidate all lists freeList.revalidate(); memberList.revalidate(); miniList.revalidate(); int y = miniList.getRelativeY() + miniList.getHeight() + 10; int newHeight; if (container.getScrollHeight() > 0) { newHeight = (container.getScrollY() * y) / container.getScrollHeight(); } else { newHeight = 0; } container.setScrollHeight(y); container.revalidateScroll(); clientThread.invokeLater(() -> client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.QUESTLIST_SCROLLBAR.getId(), WidgetInfo.QUESTLIST_CONTAINER.getId(), newHeight )); }